Transparent pdf to jpg

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
Addemar
Posts: 2
Joined: 2013-05-29T07:37:24-07:00
Authentication code: 6789

Transparent pdf to jpg

Post 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?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Transparent pdf to jpg

Post 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.
snibgo's IM pages: im.snibgo.com
indiego
Posts: 75
Joined: 2010-10-16T06:35:10-07:00
Authentication code: 8675308

Re: Transparent pdf to jpg

Post 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.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Transparent pdf to jpg

Post 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.
Addemar
Posts: 2
Joined: 2013-05-29T07:37:24-07:00
Authentication code: 6789

Re: Transparent pdf to jpg

Post 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!
Coscript Consulting
Posts: 6
Joined: 2013-06-21T06:43:23-07:00
Authentication code: 6789
Location: Philadelphia, PA

Re: Transparent pdf to jpg

Post by Coscript Consulting »

I'd like add that Adobe Acrobat keeps silent about all PDF problems it can repair.
Post Reply