前一篇文章中,刚介绍了如何读取PDF文件并转换为png图片,最终图片能正常生成,但遇到了一个问题,生成的图片背景是透明的,那么如何将透明的图片转换为白色背景呢?...找了很多 Imagick 提供的方法都没有成功,包括 setBackgroundImage() 、 setImageBackgroundImage()、 mergeImageLayers(\Imagick...imagefilledrectangle ( resource $image , int $x1 , int $y1 , int $x2 , int $y2 , int $color )
// 在 image 图像中画一个用...0, 0 是图像的最左上角。...0,
$imageWidth,
$imageHeight,
imagecolorallocate($newImage, 255, 255, 255)
);
// 重采样拷贝部分图像并调整大小