PNG -> PDF-Conversion results in corrupted image

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
michael_kaeppler
Posts: 2
Joined: 2017-10-30T03:14:43-07:00
Authentication code: 1151

PNG -> PDF-Conversion results in corrupted image

Post by michael_kaeppler » 2017-10-30T06:22:27-07:00

Hi all,
I'm trying to convert a PNG-File to PDF. The resulting PDF has red artefacts and a completely scrambled page layout.

Input and Output files are here:
https://www.dropbox.com/sh/u0k5s8re787o ... nzXca?dl=0

My command:
magick -density 300 GoldenGoose-30.png test.pdf

My OS:
Windows 10 Pro Version 10.0.15063 Build 15063

Ghostscript:
GPL Ghostscript 9.22 (2017-10-04) 32bit

ImageMagick:
Version: ImageMagick 7.0.7-8 Q16 x64 2017-10-14 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2015 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Visual C++: 180040629
Features: Cipher DPC Modules OpenMP
Delegates (built-in): bzlib cairo flif freetype jng jp2 jpeg lcms lqr openexr pangocairo png ps raw rsvg tiff webp xml zlib

Any help appreciated. This also occurs with the last 6.x build and also with older ghostscript versions...
Thanks
Michael

User avatar
GeeMack
Posts: 469
Joined: 2015-12-01T22:09:46-07:00
Authentication code: 1151
Location: Central Illinois, USA

Re: PNG -> PDF-Conversion results in corrupted image

Post by GeeMack » 2017-10-30T10:06:06-07:00

michael_kaeppler wrote:
2017-10-30T06:22:27-07:00
Hi all,
I'm trying to convert a PNG-File to PDF. The resulting PDF has red artefacts and a completely scrambled page layout.
The conversion seems to have a problem with the color profile in the original image. I got it to produce what appears to be a correct result by removing the color profile with "-strip". You might try something like this. It worked for me with IM 7.0.7-8 and GS 9.21 on Windows 10 Pro...

Code: Select all

magick -density 300 GoldenGoose-30.png -strip test.pdf

michael_kaeppler
Posts: 2
Joined: 2017-10-30T03:14:43-07:00
Authentication code: 1151

Re: PNG -> PDF-Conversion results in corrupted image

Post by michael_kaeppler » 2017-10-31T04:17:47-07:00

Many thanks, that worked for me. Is this a problem related to Ghostscript or to ImageMagick?
How did you figure this out?

Michael

User avatar
GeeMack
Posts: 469
Joined: 2015-12-01T22:09:46-07:00
Authentication code: 1151
Location: Central Illinois, USA

Re: PNG -> PDF-Conversion results in corrupted image

Post by GeeMack » 2017-10-31T07:23:09-07:00

michael_kaeppler wrote:
2017-10-31T04:17:47-07:00
Many thanks, that worked for me. Is this a problem related to Ghostscript or to ImageMagick?
How did you figure this out?
I tried converting your original PNG to a PDF and had the same problem you had. It also created the same issue when I tried converting it to a TIFF. So I tried just converting it to another PNG and got a warning about the color profile...

Code: Select all

D:\IM\Test006>magick GoldenGoose-30.png test.png

magick: profile 'icc': 'RGB ': RGB color space not permitted on grayscale PNG `test.png' @ warning/png.c/MagickPNGWarningHandler/1744.
Then I tested it by stripping the profile, and that eliminated the warning and produced what appears to be a proper output. I don't know if the software that created the original PNG included a non-compliant profile, or if maybe ImageMagick is handling the profile incorrectly. Someone who knows more about the internals of IM would have to weigh in on that.

snibgo
Posts: 9403
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: PNG -> PDF-Conversion results in corrupted image

Post by snibgo » 2017-10-31T07:37:47-07:00

In versions 6.9.5-3 and 7.0.3-5, converting to PDF works fine, and the result viewed with Adobe Reader looks good. IM doesn't use Ghostscript to write PDF.

When either version converts to PNG, I get that warning. I think it's simply a warning, that someone (GlennRP?) thinks grayscale PNG files shouldn't have colour profiles. But it does put the profile in the file. (Glenn knows far more about PNG than I do.)

I don't know what the PDF problem is, but I suspect an IM bug introduced after my versions.
snibgo's IM pages: im.snibgo.com

User avatar
glennrp
Posts: 1163
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

Re: PNG -> PDF-Conversion results in corrupted image

Post by glennrp » 2017-10-31T12:57:08-07:00

snibgo wrote:
2017-10-31T07:37:47-07:00
I
When either version converts to PNG, I get that warning. I think it's simply a warning, that someone (GlennRP?) thinks grayscale PNG files shouldn't have colour profiles. But it does put the profile in the file. (Glenn knows far more about PNG than I do.)
The PNG speciification for the iCCP chunk declares that a grayscale color profile is invalid in an RGB image. I happen to think that that requirement is a little overreaching, but there you have it.

Post Reply