0

I have a PHP function that generates high-res jpeg copies of PDF files (to be used for OCR later) and on particular pdf documents the result image has the text really blurred, kind of scaled up from a low resolution file (which is not).

I experiment setting the resolution of Imagick according to PHP docs and SO posts and I do not see any improvement.

However I noted that using the convert -density 200 command it gets the job fine really well.

So I am looking for the imagick equivalent of -density or if I can set this anywhere.

Imagick's setResolution doesn't help, nor setImageResolution.

Last resort would be to wrap the convert command in a php function, but for now would like to avoid it.

Oliver M Grech
  • 3,071
  • 1
  • 21
  • 36
  • 1
    Does [->setResolution(200,200);](https://stackoverflow.com/questions/9227014/convert-pdf-to-jpeg-with-php-and-imagemagick) not help? It seems to do the same thing as "density". Perhaps your question could be helped by including your PHP code for the conversion. – KIKO Software Dec 24 '22 at 11:36
  • I tried it, its how my code is at the moment and it makes very few difference. (I did use setResolution before reading the file in case anyone flags it) – Oliver M Grech Dec 24 '22 at 11:37
  • 1
    `setResolution()` may be dependent on [setImageUnits()](https://www.php.net/manual/en/imagick.setimageunits.php), I would use them in combination for PDF files. Please remember that questions without a [Minimal, Reproducible Example](https://stackoverflow.com/help/minimal-reproducible-example), are difficult to answer. You have to be very lucking and come across someone who experienced the exact same problem. – KIKO Software Dec 24 '22 at 11:43
  • setImageUnits is usable only after the image is read, I need an equivalent of it for before. – Oliver M Grech Dec 24 '22 at 11:56

0 Answers0