Some JPEGs Are Broken in IE7

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
adambuckley
Posts: 4
Joined: 2012-01-06T16:49:50-07:00
Authentication code: 8675308

Some JPEGs Are Broken in IE7

Post by adambuckley »

Hi All,

I’m using ImageMagick 6.7.4 on 64-bit Windows Server 2003. It’s part of an image import process, which resizes hi-res JPEGs into thumbnails.

I have noticed that a subset of the original hi-res images don’t display in IE7 or IE8. They do display in other browsers, and they also display in Windows Explorer (as thumbnails) and Windows Picture and Fax Viewer (i.e. double click an image file in Windows XP). I think the problem is something to do with fancy JPEG metadata or suchlike, as these images are coming from photo studios. identify.exe tells me that some images use TIFF or PNG internally, even though the file has a .jpg extension.

My problem is that the thumbnails generated from these problematic JPEGs also don’t display in IE7 or IE8, but they do display everywhere else.

I therefore conclude that convert.exe is faithfully reproducing the metadata (or whatever) which causes IE7 to bomb out.

I’ve also noticed that some of the generated 70x70 thumbnails are greater than 500k in size - one is even greater than 1MB.

My manual solution is to do a screen capture while the image is being shown in Windows Picture and Fax Viewer and save that as a PNG. The generated thumbnail works fine in IE7.

So my question is: Can convert.exe be instructed to throw away the metadata when writing a JPEG? Or alternatively, can ImageMagick somehow automate the process of ‘taking a screenshot’ and producing a thumbnail from that?

FYI, I have also tried using jhead.exe to remove all metadata from the hi-res images. Some of the images change colour, and the thumbnails *still* don’t show in IE7.

Many thanks in advance, Adam.
adambuckley
Posts: 4
Joined: 2012-01-06T16:49:50-07:00
Authentication code: 8675308

Re: Some JPEGs Are Broken in IE7

Post by adambuckley »

Hi, I've posted some examples which might assist.

http://adambuckley.net/ImageMagick/
  • original.jpg - hi-res image - won't display in IE7
  • thumbnail.jpg - thumbnail generated by ImageMagick - also won't display in IE7
  • huge_thumbnail1.jpg and huge_thumbnail2.jpg - examples of 70x70 jpeg images which have a huge file size.
Thumbnails are generated like this:

Code: Select all

convert.exe original.jpg -resize 70x70 output\thumbnail.jpg
Thanks again... Adam.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Some JPEGs Are Broken in IE7

Post by fmw42 »

Some browsers will not display correctly jpgs that are cmyk as is your original. Try converting it to RGB with -colorspace or better -profiles.

convert original.jpg -colorspace RGB original_cmyk.jpg

or see
http://www.imagemagick.org/Usage/formats/#profiles

If you want to remove meta data see -strip
http://www.imagemagick.org/script/comma ... 4343#strip
http://www.imagemagick.org/Usage/thumbnails/#profiles
adambuckley
Posts: 4
Joined: 2012-01-06T16:49:50-07:00
Authentication code: 8675308

Re: Some JPEGs Are Broken in IE7

Post by adambuckley »

Ha! They were CMYK images and I used your -colorspace RGB directive to fix it!

Many thanks, Adam.
adambuckley
Posts: 4
Joined: 2012-01-06T16:49:50-07:00
Authentication code: 8675308

Re: Some JPEGs Are Broken in IE7

Post by adambuckley »

I found that this form produces the smallest thumbnail filesize.

Code: Select all

convert.exe original.jpg[70x70] -colorspace RGB -strip thumbnail.jpg
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Some JPEGs Are Broken in IE7

Post by fmw42 »

you could try

convert original.jpg -colorspace RGB -strip -thumbnail 70x70 thumbnail.jpg

see -thumbnail

http://www.imagemagick.org/script/comma ... #thumbnail
NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

Re: Some JPEGs Are Broken in IE7

Post by NicolasRobidoux »

An automated but non-ImageMagick solution: http://libvips.blogspot.com/2011/12/tas ... nvert.html
Post Reply