Page 1 of 1

Unexpected borders between white object and background when converting PDF to PNG

Posted: 2018-06-21T20:48:00-07:00
by vanr
Consider the following conversion from PDF to PNG:

Source PDF: http://www.vanr.nl/ImageMagick/test.pdf

Code: Select all

mogrify.exe -density 900 -units PixelsPerInch -flatten -format png test.pdf
Result: Unexpected borders or "nasty edges" (as I call them) appear between the white circle and the background. There are no such edges between the circle and the white square located behind the circle:

Image

The "nasty edges" disappear when running the same code extended with the option...

Code: Select all

+antialias
...removing all anti-aliasing. Result:

Image

Question: How can "nasty edges" be removed without removing anti-aliasing? I am a beginner at IM.
I searched, but found no solution. Sorry about the big images: I cannot get the BBCode to scale them down.

Version: 7.0.8-2 Q16 x64 2018-06-18

Re: Unexpected borders between white object and background when converting PDF -> PNG

Posted: 2018-06-21T21:08:39-07:00
by fmw42
This command works fine for me on IM 7.0.8.2 Q16 Mac OSX using Ghostscript 9.23. Perhaps you need to upgrade ghostscript.

Code: Select all

magick mogrify -density 900 -units PixelsPerInch -background white -flatten -format png test.pdf
What is your version of Ghostscript?

Note that in IM 7, you should use magick mogrify, not mogrify. If you use the latter, you are likely getting a result from IM 6.

See http://imagemagick.org/script/porting.php#cli

Re: Unexpected borders between white object and background when converting PDF to PNG

Posted: 2018-06-21T22:50:53-07:00
by vanr
Updating from GhostScript v9.20 to v9.23 solved this issue:

Image

@fmw42: You have been very helpful, thank you very very much!! Also thanks for the note.