Page 1 of 1

Transparent pdf to jpg

Posted: 2013-05-29T08:04:02-07:00
by Addemar
I'm having a problem with a transparent pdf that contains images with a shadow.
When I use convert, I cant seem to get the shadow effect to be preserverd. Instead it becomes a solid color.

I use the following command (ImageMagick 6.3.7), which has worked great for any other PDF:

Code: Select all

convert -density 288 -resize 25% -colorspace CMYK example.pdf -append -colorspace RGB example.jpg
But for this specific PDF with shadows:
http://dev.addemar.com/imagemagick/example.pdf
The image becomes:
http://dev.addemar.com/imagemagick/example_convert.jpg


I have also been trying with calling Ghostscript (8.62) directly:

Code: Select all

gs -dNOPAUSE -dBATCH -dUseCIEColor -sDEVICE=jpeg -r72 -sOutputFile=example_gs.jpg example.pdf
And this results into the following image, where shadow is preserved:
http://dev.addemar.com/imagemagick/example_gs.jpg


Is there a way (an option I'm missing) to solve this problem using convert?

Re: Transparent pdf to jpg

Posted: 2013-05-29T08:36:36-07:00
by snibgo
Your version of IM is ancient. With a more recent version (6.8.5-0 on Windows 7), the result looks exactly as it does with Adobe Reader.

However, the conversion also throws up a warning:

Code: Select all

   **** Warning: format of the startxref line in this file is invalid.

   **** This file had errors that were repaired or ignored.
   **** Please notify the author of the software that produced this
   **** file that it does not conform to Adobe's published PDF
   **** specification.

Re: Transparent pdf to jpg

Posted: 2013-05-29T15:39:43-07:00
by indiego
Normal JPG does not support transparency (only J2K). You can try to use PNG instead, but I doubt that the transparency will survive the 'flattening'. Just give it a try.

I also made a syntax check in Acrobat, no PDF problems found.

Re: Transparent pdf to jpg

Posted: 2013-05-29T15:50:58-07:00
by fmw42
convert -density 288 -resize 25% -colorspace CMYK example.pdf -append -colorspace RGB example.jpg
resize needs to be after reading the pdf and probably after converting the PDF to RGB also to save the transparency you need to save to png or flatten over white for example

convert -density 288 -colorspace CMYK example.pdf -append -colorspace RGB -resize 25% example.png

Also try converting the PDF to RGB when reading


convert -density 288 -colorspace RGB example.pdf -resize 25% -append example.png

These two commands work for me in IM 6.8.5.8 Q16


convert -density 288 -colorspace sRGB example.pdf -resize 25% -append example.jpg

convert -density 288 -colorspace sRGB example.pdf -resize 25% -append -background white -flatten example.jpg


Note that I have to use sRGB for the current IM, but you need to use RGB for such an old version.

Re: Transparent pdf to jpg

Posted: 2013-05-30T02:55:06-07:00
by Addemar
snibgo wrote:Your version of IM is ancient. With a more recent version (6.8.5-0 on Windows 7), the result looks exactly as it does with Adobe Reader.
I tried with a more recent version (on a more recent unix system) and the result was correct.
So this is solved, thx.

And thx fmw42 for the extra tips!

Re: Transparent pdf to jpg

Posted: 2013-06-21T09:35:46-07:00
by Coscript Consulting
I'd like add that Adobe Acrobat keeps silent about all PDF problems it can repair.