Page 1 of 1

Weird issue with a Mac created JPG

Posted: 2008-05-14T05:19:05-07:00
by PCPete
Hello all,

I came across a weird result for a file upload / image analyzer I'm writing. When a person uploads the file, I check it's color space, density, file size etc. Nothing major. However, I get a strange error for JPEGs that are created on a mac (photoshop), and then uploaded by a PC.

If I create the jpeg, and upload it - no error
If my co-worker creates the image and uploads it - no error
if I create the image and send to my coworker and he uploads it - no error
if I use the image he created, I get the following error:

Code: Select all

identity: 450: Not a JPEG file: starts with 0x00 0x0b 
And oddly enough, if I try to preview this file in windows it does not work. However, I can open it in photoshop and view it there and it reports that it is a jpeg. This is not so much an imageMagick problem but I was wondering if t here was anything specific I could look for in such a file that would allow me to account for this programmatically. If anyone wants to look into this I can provide one such file that demonstrates this odd behavior.

thanks!

Re: Weird issue with a Mac created JPG

Posted: 2008-05-14T10:20:52-07:00
by fmw42
Are you using JPEG created with QuickTime? I suspect that is the problem. Try creating the JPEG in Photoshop without the use of QT.

Re: Weird issue with a Mac created JPG

Posted: 2008-05-14T10:25:37-07:00
by Bonzo
I do not know why it is happening but digging back into my memory a jpg file starts with "FF" ( confirmed by looking at a couple of my images ). This basicly tells the software what the image type is without the .jpg extension.
Yours must start with a 00. This is what the Wiki says
A JPEG image contains a sequence of markers, each of which begins with a 0xFF byte followed by a byte indicating what kind of marker it is. Some markers consist of just those two bytes; others are followed by two bytes indicating the length of marker-specific payload data that follows. (The length includes the two bytes for the length, but not the two bytes for the marker.) Some markers are followed by entropy-coded data; the length of such a marker does not include the entropy-coded data.
There are other Start Of Frame markers that introduce other kinds of JPEG.

Since several vendors might use the same APPn marker type, application-specific markers often begin with a standard or vendor name (e.g., "Exif" or "Adobe") or some other identifying string.

At a restart marker, block-to-block predictor variables are reset, and the bitstream is synchronized to a byte boundary. Restart markers provide means for recovery after bitstream error. Since the runs of macroblocks between restart markers may be independently decoded, these runs may be decoded in parallel.
http://en.wikipedia.org/wiki/JPEG

I downloaded a hex editor to view the data; there may be a better way but it was a couple of years ago when I was looking at this before. Take a look at your different images and see what they have.