PDF to TIF produces all or mostly black pages

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
pmcgrath90
Posts: 5
Joined: 2014-07-01T09:24:26-07:00
Authentication code: 6789

PDF to TIF produces all or mostly black pages

Post by pmcgrath90 »

Using convert.exe to produce .tif files from PDF's. The PDFs come from vendors as email attachments so I have no control over creation. 95% of the time everything works fine. From certain vendors I get PDFs that, when converted, are all black or mostly black. Here is the command:

convert.exe -density 300 <input.pdf> -monochrome -compress Group4 <output.tif>

I have played around with setting -alpha off, -flatten, -background to none or white; no luck.

here is a link to the pdf if you want to test: http://1drv.ms/1pH8H1M

This PDF converts fine using GhostScript with: gswin64c -q -dNOPAUSE -dUseCropBox -sDEVICE=tiffg4 -r300 -sOutputFile=<outputfile.tif> <inputfile.pdf> -c quit

Other Info:
Running on Windows Server 2008. Testing on Windows 8.1

Version: ImageMagick 6.8.9-2 Q16 x64 2014-05-27 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2014 ImageMagick Studio LLC
Features: DPC Modules OpenMP
Delegates: bzlib cairo freetype jbig jng jp2 jpeg lcms lqr pangocairo png ps rsvg tiff webp xml zlib

Thanks,
Pat McGrath
GSWP
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: PDF to TIF produces all or mostly black pages

Post by fmw42 »

this works fine for me on IM 6.8.9.5 Q16 Mac OSX

Code: Select all

convert -density 300 test1.pdf -alpha off -monochrome -compress group4 test1.tif
Perhaps you need to upgrade your Ghostscript and/or libtiff

See

convert -list format

for your current versions
pmcgrath90
Posts: 5
Joined: 2014-07-01T09:24:26-07:00
Authentication code: 6789

Re: PDF to TIF produces all or mostly black pages

Post by pmcgrath90 »

Thanks for the quick reply.

-alpha off does not seem to have any effect.

from the -list command:

TIFF* TIFF rw+ Tagged Image File Format (LIBTIFF, Version 4.0.3)
TIFF64* TIFF rw- Tagged Image File Format (64-bit) (LIBTIFF, Version 4.0.3)

Not seeing GhostScirpt in the -list command

gs9.14 is installed on the pc.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: PDF to TIF produces all or mostly black pages

Post by fmw42 »

Your pdf image has transparency. That may be the issue


Check your delegates.xml file and be sure it is using -sDEVICE=pngalpha for ps:alpha rather than pnmraw


<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""/>
pmcgrath90
Posts: 5
Joined: 2014-07-01T09:24:26-07:00
Authentication code: 6789

Re: PDF to TIF produces all or mostly black pages

Post by pmcgrath90 »

Here is the line copied as is from my 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""/>


I have also updated to 6.8.9-5 Q16, and installed the Q8 version of ImageMagick. No joy with either. Same result, black pages.

I may try the x86 versions for fun and giggles.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: PDF to TIF produces all or mostly black pages

Post by fmw42 »

Sorry. I am out of ideas. Perhaps some other Windows user can test this. On my Mac it works fine.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: PDF to TIF produces all or mostly black pages

Post by snibgo »

Code: Select all

convert -density 300 test11.pdf -alpha off -monochrome -compress Group4 o.tif
Works fine for me, with or without "-alpha off", IM 6.8.9-0 Q16 on Windows 8.1, Ghostscript 9.10.
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: PDF to TIF produces all or mostly black pages

Post by fmw42 »

Delegates: bzlib cairo freetype jbig jng jp2 jpeg lcms lqr pangocairo png ps rsvg tiff webp xml zlib
I do not see gslib in this list. Are you sure IM can find Ghostscript? I do not know if it shows in the list on Windows, but it does show in the list for Linux/Mac OS.

GS is needed to properly read PDF files.
pmcgrath90
Posts: 5
Joined: 2014-07-01T09:24:26-07:00
Authentication code: 6789

Re: PDF to TIF produces all or mostly black pages

Post by pmcgrath90 »

I uninstalled both GS and all version of IM from my test pc and started from scratch.

First installed just IM 6.8.9-5 Q16 x64. Ran the convert, it failed as expected not being able to find GS.

I then installed GS 9.14. Ran the convert. This time no error, but output is still black.

I'm installing GS 9.10 to give that a try.

@fnw42 I'm a little confused by your post. Where did you find that Delegates list?
pmcgrath90
Posts: 5
Joined: 2014-07-01T09:24:26-07:00
Authentication code: 6789

Re: PDF to TIF produces all or mostly black pages

Post by pmcgrath90 »

Further Testing:

Uninstalled GS 9.14, installed GS 9.10. Ran convert. WORKED! :D

to verify; uninstalled GS 9.10, installed GS9.14. Ran convert. BLACK. :(

So it seems to be an issue with the interaction between IM and GS 9.14.

if I just run the file through GS 9.14 with

gswin64c -q -dNOPAUSE -dUseCropBox -sDEVICE=tiffg4 -r300 -sOutputFile=<outputfile.tif> <inputfile.pdf> -c quit

It works fine.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: PDF to TIF produces all or mostly black pages

Post by fmw42 »

@fnw42 I'm a little confused by your post. Where did you find that Delegates list?
On my system it is installed at /usr/local/etc/ImageMagick-6/delegates.xml

However, the original file is included in the source code downloads folder in folder config.
Post Reply