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

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
vanr
Posts: 2
Joined: 2018-06-21T18:34:18-07:00
Authentication code: 1152

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

Post 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
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

Post 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
vanr
Posts: 2
Joined: 2018-06-21T18:34:18-07:00
Authentication code: 1152

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

Post 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.
Post Reply