Opening a PDF File - All that is visible is transparent checker board

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.
zoltron_rulez
Posts: 5
Joined: 2015-09-15T09:11:46-07:00
Authentication code: 1151

Opening a PDF File - All that is visible is transparent checker board

Post by zoltron_rulez »

All,

My environment:
Windows 7-64 bit
Image Magic - 6.9.1-Q16 (64-bit)
Ghostscript - 9.16

I have a PDF file that I needed to convert to jpg file. Unfortunately, the conversion did not work,- all I got was a blank output.
Therefore, I used IMDisplay to open the PDF file and all I see is transparent checker board.

Interestingly, we have an older machine (Win 2003 server 64bit) that runs 6.7.3-6, Ghostscript 9.04. When I open the same PDF file, it opens it fine. Also, the conversion works fine.

Please help me resolve this problem.

Regards

User avatar
fmw42
Posts: 26383
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Opening a PDF File - All that is visible is transparent checker board

Post by fmw42 »

You should probably post your PDF file to some place such as Dropbox.com and put the URL here, so other Windows user can test. But it would seem to be a problem with your Ghostscript and not IM. Does your PDF have transparency. If so, check what your sDEVICE is in your delegates.xml file.


<delegate decode="ps:alpha" stealth="True" command=""gs" -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=pngalpha" -dTextAlphaBits=%u -dGraphicsAlphaBits=%u "-r%s" %s "-sOutputFile=%s" "-f%s" "-f%s""/>

Is your PDF in CMYK or RGB?

zoltron_rulez
Posts: 5
Joined: 2015-09-15T09:11:46-07:00
Authentication code: 1151

Re: Opening a PDF File - All that is visible is transparent checker board

Post by zoltron_rulez »

I figured it may have to do w/ Ghost script or the file format, but I need to know the cause and fix for this issue. I am not sure if the PDF uses transparency since I don't know how to check this. It is generated by one of our scanners.

Here"s the pdf:
https://drive.google.com/file/d/0Bxzqjx ... sp=sharing

Command I am using:
convert t5.pdf -thumbnail 500x500 -trim t5.jpg

I checked the sDevice in delegages for ps:alpha and it is correct, here it is copied from delegates.xml:

<delegate decode="ps:alpha" stealth="True" command=""@PSDelegate@" -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=pngalpha" -dTextAlphaBits=%u -dGraphicsAlphaBits=%u "-r%s" %s "-sOutputFile=%s" "-f%s" "-f%s""/>

User avatar
fmw42
Posts: 26383
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Opening a PDF File - All that is visible is transparent checker board

Post by fmw42 »

Your file is grayalpha. You can see what your file meta data is by using

Code: Select all

identify -verbose t5.PDF
But the alpha channel is fully opaque. JPG does not support transparency, so there is no reason for your output to be fully transparent. Are you sure of your command and using JPG for output?

This works fine for me on IM 6.9.2.1 Q16 Mac OSX and Ghostscript 9.10

Code: Select all

convert t5.PDF t5.jpg
Try

Code: Select all

convert -alpha off t5.PDF t5.jpg
Also you would get better quality using supersampling.

Code: Select all

convert -alpha off -density 288 t5.PDF -resize 25% t5.jpg
Normal density is 72 by default, so 288 = 72*4 and thus we resize by 1/4 = 25%. Or don't resize at all and get a 4x larger resulting image.

If these do not work, try backing off your GS version. Or upgrading IM. Perhaps there were issues with your version of IM.

Code: Select all

convert -version
will tell you the exact version of IM 6.9.1.x

zoltron_rulez
Posts: 5
Joined: 2015-09-15T09:11:46-07:00
Authentication code: 1151

Re: Opening a PDF File - All that is visible is transparent checker board

Post by zoltron_rulez »

I guess I should of stated, what exactly I was trying to achieve. Our software use IM to create thumb nails of our PDF drawings (100x100, 500x500 thumbnails to be exact). These thumbnails are jpg but could be just as well png.

Regardless, I tried your suggestions, same issue, blank output. I will now try downgrading GS, and try latest IM. I'll post my findings, thank you for your prompt help.

User avatar
fmw42
Posts: 26383
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Opening a PDF File - All that is visible is transparent checker board

Post by fmw42 »

Before changing GS, try just upgrading IM. If you still get the same issue, then downgrade your GS.

I still don't see why you get fully transparent results if you are using JPG for the output. That might be the case, though very strange, if you are using PNG.

zoltron_rulez
Posts: 5
Joined: 2015-09-15T09:11:46-07:00
Authentication code: 1151

Re: Opening a PDF File - All that is visible is transparent checker board

Post by zoltron_rulez »

"I still don't see why you get fully transparent results if you are using JPG for the output. That might be the case, though very strange, if you are using PNG."

That's what happened when I had trouble w/ the convert command and decided to use IMDisplay to open the actual PDF file I was converting.
I probably was not clear about this.

User avatar
fmw42
Posts: 26383
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Opening a PDF File - All that is visible is transparent checker board

Post by fmw42 »

As far as I can tell, the PDF has a fully opaque alpha channel. So it should not be showing as fully transparent. Try upgrading IM or use another viewer.

zoltron_rulez
Posts: 5
Joined: 2015-09-15T09:11:46-07:00
Authentication code: 1151

Re: Opening a PDF File - All that is visible is transparent checker board

Post by zoltron_rulez »

Well, success. Apparently, latest, greatest of IM doesn't work that well with gs 9.16. I have downgraded my gs to 9.10 (what you have) and it works now. It would be interesting to know why ... since it is quite difficult to figure these things on your own,- w/out your help I would be stuck for a while.
Thanks for great and quick support.

User avatar
fmw42
Posts: 26383
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Opening a PDF File - All that is visible is transparent checker board

Post by fmw42 »

Magick -- please let us know if this is an IM issue with GS 9.16 or a GS bug.

User avatar
magick
Site Admin
Posts: 11254
Joined: 2003-05-31T11:32:55-07:00

Re: Opening a PDF File - All that is visible is transparent checker board

Post by magick »

Likely a GS bug. Let's eliminate ImageMagick. Try this:
  • gs -sDEVICE=pnmraw -sOutputFile=t5.pnm t5.pdf
gs 9.16 returns a completely white image. Other viewer display the image properly. GS likely bails on this image for security reasons. It detects and reports a problem with the content stream.

User avatar
fmw42
Posts: 26383
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Opening a PDF File - All that is visible is transparent checker board

Post by fmw42 »

On my IM 6.9.2.1 Q16 and GS 9.10, I get an error and no pnm image. Perhaps I am not running it correctly for my version of GS?


gs -sDEVICE=pnmraw -sOutputFile t5.pnm t5.pdf

Code: Select all

GPL Ghostscript 9.10 (2013-08-30)
Copyright (C) 2013 Artifex Software, Inc.  All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Error: /undefinedfilename in (t5.pnm)
Operand stack:

Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push
Dictionary stack:
   --dict:1173/1684(ro)(G)--   --dict:0/20(G)--   --dict:77/200(L)--
Current allocation mode is local
Last OS error: Invalid argument
GPL Ghostscript 9.10: Unrecoverable error, exit code 1

However,

Code: Select all

convert t5.PDF t5.jpg
works fine.

User avatar
magick
Site Admin
Posts: 11254
Joined: 2003-05-31T11:32:55-07:00

Re: Opening a PDF File - All that is visible is transparent checker board

Post by magick »

Use -sOutputFile=t5.pnm, no space.

User avatar
fmw42
Posts: 26383
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Opening a PDF File - All that is visible is transparent checker board

Post by fmw42 »

magick wrote:Use -sOutputFile=t5.pnm, no space.
Worked fine with IM 6.9.2.1 Q16 Mac OSX and GS 9.10

gs -sDEVICE=pnmraw -sOutputFile=t5.pnm t5.pdf

Code: Select all

GPL Ghostscript 9.10 (2013-08-30)
Copyright (C) 2013 Artifex Software, Inc.  All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Processing pages 1 through 1.
Page 1
>>showpage, press <return> to continue<<

GS>quit

246246
Posts: 200
Joined: 2015-07-06T07:38:22-07:00
Authentication code: 1151

Re: Opening a PDF File - All that is visible is transparent checker board

Post by 246246 »

zoltron_rulez wrote:Well, success. Apparently, latest, greatest of IM doesn't work that well with gs 9.16. I have downgraded my gs to 9.10 (what you have) and it works now.
FYI, it seems to work with gs 9.15.

[EDIT]
It is a known bug of Ghostscript.
http://bugs.ghostscript.com/show_bug.cgi?id=696005

Replace pdf_draw.ps with current repository one, it works.
So this issue will be expected to be solved when GhostScript 9.18 will be released in next few weeks (announced on 14-Sep-2015 at http://bugs.ghostscript.com/show_bug.cgi?id=696197 )

Locked