Page 1 of 1
Converting PDF to JPEG is giving negative output
Posted: 2015-09-02T06:01:42-07:00
by HaroldWindt
ImageMagick 6.9.1-0
Ghostscript 9.15
Environment - Linux
We are getting a black background JPEG file when we are trying to conveert PDF to JPEG. Below is the command we are using
convert -alpha off -units pixelsperinch -resize 800X600 Dropbox.pdf[0] -profile "sRGB Color Space Profile.icm" -profile "sRGB Color Space Profile.icm" Dropbox.jpg
File Name - Dropbox.pdf
PDF File Location -
https://www.dropbox.com/s/7ehqobvz7lr7g ... x.pdf?dl=0
Output JPEG file -
https://www.dropbox.com/s/89i2hv5a6sbwa ... x.jpg?dl=0
The same PDF when we tried converting to JPEG using older version of IM & GS its working fine
ImageMagick 6.5.4-7
Ghostscript 8.70 (2009-07-31)
Can some one help to understanding what is causing the issue with newer version of IM for these specific PDF files
Re: Converting PDF to JPEG is giving negative output
Posted: 2015-09-02T08:56:52-07:00
by fmw42
The following command works for me on IM 6.9.2.0 Q16 Mac OSX and ghostscript 9.10_2. Unix syntax. Note -resize is after the input. Also you only need one profile, since your input image has no profile.
Code: Select all
convert -units pixelsperinch -density 288 Dropbox.pdf[0] \
-alpha off \
-resize 800x600 \
-profile /Users/fred/images/profiles/sRGB.icc \
Dropbox.jpg
check you delegates.xml file for the sDEVICE being used. Mine is
<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""/>
Re: Converting PDF to JPEG is giving negative output
Posted: 2015-09-04T08:08:05-07:00
by HaroldWindt
Tried a simple convert using latest IM & GS and still the output JPEG file is black
convert C:\Users\Admin\Desktop\DropBox.pdf[0] C:\Users\Admin\Desktop\DropBox.jpg
Operating System - Windows 7 (64bit)
ImageMagick Version - 6.9.2
Ghost Script Version - 9.16
Re: Converting PDF to JPEG is giving negative output
Posted: 2015-09-04T09:41:23-07:00
by snibgo
The PDF has a transparent (ie "transparent-black") background. JPG doesn't have transparency, so it removes the transparency, leaving black. If you prefer white:
Code: Select all
convert Dropbox.pdf[0] -background White -flatten x.jpg
Re: Converting PDF to JPEG is giving negative output
Posted: 2015-09-04T09:55:32-07:00
by 246246
It seems -alpha remove will generate white background.
(As internal png generated by pngalpha has white background.)
Cite from
http://ghostscript.com/doc/current/Devices.htm
Code: Select all
The pngalpha device responds to the following option:
-dBackgroundColor=16#RRGGBB (RGB color, default white = 16#ffffff)
Re: Converting PDF to JPEG is giving negative output
Posted: 2015-09-04T10:46:03-07:00
by fmw42
If the sDEVICE is not pngalpha (for example pnmraw), the alpha off may not give a white background. So snibgo's solution is probably more reliable. But you may need pngalpha for GS to properly read the image, since it has transparency.
Re: Converting PDF to JPEG is giving negative output
Posted: 2015-09-05T07:26:44-07:00
by 246246
Just checking:
$ gs -dQUIET -dSAFER -dBATCH -dNOPAUSE -sDEVICE=jpeg -dFirstPage=1 -dLastPage=1 -sOutputFile=- DropBox.pdf | convert - show: # white background
$ gs -dQUIET -dSAFER -dBATCH -dNOPAUSE -sDEVICE=pnmraw -dFirstPage=1 -dLastPage=1 -sOutputFile=- DropBox.pdf | convert - jpeg:- | display - # white background
$ gs -dQUIET -dSAFER -dBATCH -dNOPAUSE -sDEVICE=pngalpha -dFirstPage=1 -dLastPage=1 -sOutputFile=- DropBox.pdf | convert - -alpha remove jpeg:- | display - # white background
$ gs -dQUIET -dSAFER -dBATCH -dNOPAUSE -sDEVICE=pngalpha -dBackgroundColor=16#000000 -dFirstPage=1 -dLastPage=1 -sOutputFile=- DropBox.pdf | convert - -alpha remove jpeg:- | display - # black background
Re: Converting PDF to JPEG is giving negative output
Posted: 2015-09-08T00:18:52-07:00
by HaroldWindt
HaroldWindt wrote:ImageMagick 6.9.1-0
Ghostscript 9.15
Environment - Linux
We are getting a black background JPEG file when we are trying to conveert PDF to JPEG. Below is the command we are using
convert -alpha off -units pixelsperinch -resize 800X600 Dropbox.pdf[0] -profile "sRGB Color Space Profile.icm" -profile "sRGB Color Space Profile.icm" Dropbox.jpg
The same command stated above is giving a good output with the below versions of ImageMagick and GhostScript
ImageMagick 6.8.8-7Q16 x86_64
Ghostscript 9.10
So its working fine with the older version, something broke in the newer version whether its ImageMagick or Ghostscipt