我想将图像文件更改为jpeg格式,如下所示:
$img_real_path = realpath(".") . "/" .$dest;
echo $img_real_path;
$image = new Imagick();
$image->readImage($img_real_path);
$image->setImageFormat("jpeg");
但图像格式与原样相同。我做错了什么?
答案 0 :(得分:1)
您未使用$image->imageWriteFile()
将此添加到您的代码中:
$image->imageWriteFile (fopen ($image_real_path, "wb"));
它应该是这样的:
$img_real_path = realpath(".") . "/" .$dest;
echo $img_real_path;
$image = new Imagick();
$image->readImage($img_real_path);
$image->setImageFormat("jpeg");
$image->imageWriteFile (fopen ($image_real_path, "wb"));