Search code examples
imagepdfpnggimp

Converting PDF to PNG imagemagick vs GIMP


I'm trying to batch convert PDF's to PNG's. Previously, this was always done manually through GIMP by importing a PDF, then converting it to PNG.

With the script that I wrote, this should all be done automatically. But for some reason, the image quality I get from using

convert \ -density 300 \ -adaptive-resize 2048 \ -define png:compression-level=9 \ "File1" "File2"

Doesn't have the same "quality" compared to doing it via GIMP. See the image below for the difference in image quality.

In GIMP, I don't change much to the image. When I import the PDF, I change the resolution to 2048 pixels. When I convert and export it to PNG, I use all the default values GIMP offers, nothing fancy.

Changing the density to a higher or lower value doesn't do anything to the image. Also changing adaptive-resizing to normal resizing doesn't do much.

In the example image, both pictures are 2048 pixels wide. As you can see the lower image has a lot thicker/blurrier lines.

Example image comparison:


Solution

  • So, I have found a way around my problem. Increasing the PPI kind of helped but still not as much as I would have liked it to. Eventually I added this:

    -channel A -fx "p*(p>0.2?22:0)"  
    

    Just some simple piece of code I found somewhere around here. It checks for the Alpha levels in the picture and if it's below a certain threshold it will just remove or "make the pixel" transparent. If it's over the threshold it will just boost the pixel to maximum visibility. Combined with the high PPI I dont get any "half pixels" anymore.