I'm using php 7.2 and ImageMagick-7.0.8-12. I'm using it to create thumbnails like so:
function thumbimg($sourcePath, $thumbPath) {
try {
if (file_exists($sourcePath)) {
$imagick = new Imagick();
$imagick->readImage($sourcePath);
$imagick->setImageFormat("jpg");
header('Content-Type: image/jpeg');
$imagick->writeImage($thumbPath);
$imagick->clear();
$imagick->destroy();
chmod($thumbPath, 0755);
return;
}
} catch (ImagickException $e) {
echo $this->raiseError('Could not save image to file: ' . $e->getMessage(), IMAGE_TRANSFORM_ERROR_IO);
}
return;
}
The php script does return an echo'ed JSON as designed, but when I look at the network return preview it shows a blank image with the post link to that script. This behavior starts on the line $imagick = new Imagick(); Prior to that it behaves normally. While I do get the desired JSON, it messes with other functions that produce outputs.
$imagick->destroy();is deprecated and unnecessary.