Page 1 of 1

PDF to JPG can not be viewed in IE6 or IE7

Posted: 2008-09-26T16:29:04-07:00
by brettalton
So, for work, I was asked to convert PDF files into JPG images.

Immediately I thought of ImageMagick and wrote this:

Code: Select all

for file in `ls *.pdf`; do
	convert $file -resize 800x800 `echo $file | sed 's/\.pdf$/\.jpg/'`
done
Unfortunately, for some reason, the .jpg file can not show up in IE7 on Windows XP and Vista, nor IE6 through Wine on Linux. It works in Firefox, GIMP, Image Viewer (Gnome), some KDE applications, etc.

Is there a header I'm missing?

I also ran the command 'file' to see if the file was recognized as a JPG. It was of course, including the .jpg that was converted from a PDF file before I was hired (in folder 'old').
$ file page01.jpg
page01.jpg: JPEG image data, JFIF standard 1.01

$ file old/page01.jpg
old/page01.jpg: JPEG image data, JFIF standard 1.01

Re: PDF to JPG can not be viewed in IE6 or IE7

Posted: 2008-09-26T19:28:55-07:00
by fmw42
I am on a Mac and in Safari, all I see is black. It shows fine in Firefox and Opera.

I would question one of several things.

What is the format of the image in the PDF and is it a "good" image? Can you extract that image from your PDF and display it in any/every browser?

Is the image in your PDF in RGB or CMYK format?

Try doing the convert on a single image with a simple command line? Perhaps add -colorspace RGB.

I am not too sure of this, but try

convert -colorspace RGB image.pdf -resize 800x800 output.jpg

Try also some other format like PNG or GIF and see if that displays in any/every browser.

Someone like Anthony, may be able to give you more information about properly converting from PDF to JPG and any issues there. But see

http://www.imagemagick.org/Usage/formats/
(particularly about JPG and potentially about changing colorspaces and profiles, if that is relevant, and also other formats section regarding PDF). Note I believe IM uses Ghostscript to convert from PDF, so your Ghostscript may be an/the issue.

Hopefully, someone more knowledgeable, such as Anthony or Magick, can help you more directly.

Re: PDF to JPG can not be viewed in IE6 or IE7

Posted: 2008-09-26T20:09:45-07:00
by magick
Add -interlace none to your command line to turn off progressive encoding.

Re: PDF to JPG can not be viewed in IE6 or IE7

Posted: 2008-09-26T21:03:13-07:00
by fmw42
I am no expert on these matters, but I looked at the verbose info:

identify -verbose page01.jpg
Image: page01.jpg
Format: JPEG (Joint Photographic Experts Group JFIF format)
Class: DirectClass
Geometry: 618x800+0+0
Resolution: 72x72
Print size: 8.58333x11.1111
Units: PixelsPerInch
Type: ColorSeparation
Endianess: Undefined
Colorspace: CMYK
...
Interlace: None


And it appears to be CMYK with no interlace. So I suspect not all browsers can display CMYK jpg images. You can try converting to RGB.

I am not too sure how you do that, but you can try (according to the search results below):

convert -colorspace RGB image.pdf -resize 800x800 output.jpg



The page at http://www.imagemagick.org/Usage/formats/ may help.

You can also search these archives for "CMYK PDF" topics and see if this has been answered before, which appears to be the case.

See for example these two:
viewtopic.php?f=3&t=11514&p=37094&hilit=CMYK+PDF#p37094
viewtopic.php?f=1&t=10933&hilit=cmyk+pdf

Re: PDF to JPG can not be viewed in IE6 or IE7

Posted: 2008-10-10T12:47:08-07:00
by brettalton
Thanks everyone, it was because it was in CMYK mode, you were all right!

Code: Select all

-colorspace RGB
Does the trick! Thanks!

Re: PDF to JPG can not be viewed in IE6 or IE7

Posted: 2011-08-16T00:19:14-07:00
by sushil.prajapati
Thanks everyone it works for me... :)

-colorspace RGB

Re: PDF to JPG can not be viewed in IE6 or IE7

Posted: 2011-08-17T23:08:38-07:00
by anthony
brettalton wrote:Immediately I thought of ImageMagick and wrote this:

Code: Select all

for file in `ls *.pdf`; do
	convert $file -resize 800x800 `echo $file | sed 's/\.pdf$/\.jpg/'`
done
Not really part of the actual problem but what about using...

Code: Select all

   convert "$file" -resize 800x800 -set filename:f '%t'  '%[filename:f].jpg' 
Note that %t does not include the directory path component %d

instead of the sub-shell expression. It then does not matter if the input is PDF, postscript, or something else!