3

I'm running ghostscript 9.22, libpng 1.6.34, and imagemagick 7.0.7-11 Q16

Here is the command that replicates the issue:

convert -density 400 icon.pdf -scale 1024x1024 ./appicon-1024x1024.png

Here is a link to the input PDF: https://www.pdf-archive.com/2017/12/06/icon/

Here is the output I see, with streaky horizontal line artifacts: app-icon

Interestingly, turning off antialiasing resolves the issue, but is not suitable for our use case.

jrlocke
  • 97
  • 5
  • A quick workaround (pending the code to be reviewed) would be to convert without antialiasing to 2x, 4x, or more of the target size, then resizing that *with* antialiasing. – Jongware Dec 07 '17 at 09:49

3 Answers3

1

I am running into this same issue and I think that Ghostscript 9.22 is the problem. I can reproduce the issue by running Ghostscript directly:

gs -dSTRICT -dDOINTERPOLATE -dNOPAUSE -dEPSCrop -dBATCH -sOutputFile=test.png -sDEVICE=pngalpha /path/to/broken.pdf

I've also tested with Ghostscript 9.21, which works as expected.

When imagemagick's convert command is run with +antialias, it passes different switches to ghostscript.

You can use the -verbose switch to tell imagemagick to print out the entire command it is using to invoke gs:

$ convert -verbose test.pdf test.png

Which yields:

'gs' -sstdout=%stderr -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 '-sDEVICE=pamcmyk32' -dTextAlphaBits=4 -dGraphicsAlphaBits=4 '-r72x72' -g1728x1728 -dEPSCrop ...

With the antialias flag set:

$ convert -verbose +antialias test.pdf test-with-antialias-flag.png

gives us:

'gs' -sstdout=%stderr -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 '-sDEVICE=pamcmyk32' -dTextAlphaBits=1 -dGraphicsAlphaBits=1 '-r72x72' -g1728x1728 -dEPSCrop

There are a couple of different switches set there. Based on some experimentation running gs directly, I figured out that -dGraphicsAlphaBits seems to be the culprit. If it is set to a value greater than 1, the lines appear in the output.

So there are a few potential workarounds:

  • Edit imagemagick's delegates.xml to force -dGraphicsAlphaBits to 1.
  • Install ghostscript 9.21, which seems unaffected.
  • Convert at double dimensions and then size down, as suggested above.
Dave
  • 106
  • 1
  • 3
1

Update ghostscript to version 9.23 and reinstall imagemagick.

jan-glx
  • 7,611
  • 2
  • 43
  • 63
0

This command works perfectly fine for me using ImageMagick 6.9.9.25 Q16 Mac OSX and Ghostscript 9.21 and libpng @1.6.30_0.

convert -density 400 icon.pdf -scale 1024x1024 test.png

enter image description here

I suspect it is either your Ghostscript or libpng version. Try upgrading.

fmw42
  • 46,825
  • 10
  • 62
  • 80
  • 1
    I'm running ghostscript 9.22, libpng 1.6.34, and imagemagick 7.0.7-11 Q16, all of which ahead of your working versions. – jrlocke Dec 06 '17 at 15:05
  • I tried with IM 7.0.7.13 Q16 Mac OSX Sierra with Ghostscript 9.21 and libpng @1.6.30_0 and it still works fine for me. – fmw42 Dec 06 '17 at 17:27