Resizing .eps and saving as .jpg with Imagick in PHP
I am trying to resize and save a .eps file to .jpeg using Imagick,
I tried to resizeImage
, scaleImage
, setImageResolution
and I tried to write in .png, but the result is very bad. I tried to set the compression quality to 100 and I tried various resizeImage and blur options.
$imagick = new Imagick();
$imagick->readImage($file);
$imagick->resizeImage($width, $height, imagick::FILTER_CATROM, 1);
$imagick->setImageFormat('jpeg');
return $imagick->writeImage($name);
Is there some magic I am missing?
Edit: I read somewhere about similar Ghostscript related issues, I have a Ghostscript port installed. How can I check if it works?
source to share
You must set the render resolution before reading the file:
$imagick = new Imagick();
$imagick->setResolution(300, 300);
$imagick->readImage($file);
If the result is still bad, it means ImageMagick is using the embedded TIFF preview from EPS instead of the actual PostScript data. Make sure Ghostscript is installed and can be found as described in this answer .
source to share