Discussion:
Adding JFIF headers to JPEG without reencoding?
(too old to reply)
Alexandros Diamantidis
2004-12-31 19:00:59 UTC
Permalink
Hi all! The following question is off-topic, but I hope someone here
knows the answer:

I was given some JPEG files that the GIMP opens fine, but Mozilla and
some image viewers can't display or give warnings about errors. It seems
that they're not in standard JFIF format, because file(1) says:

KARE1.jpg: JPEG image data

while for other .jpegs it says:

dgrid.jpg: JPEG image data, JFIF standard 1.01

Is there a way to make them conform to JFIF without re-encoding?
I tried using the jpegtran tool, but it seems to write its output
in the same format as its input.

Thanks in advance, and my best wishes for the new year!
--
Alexandros Diamantidis * ***@hellug.gr
Michael Meissner
2005-01-01 13:39:34 UTC
Permalink
Post by Alexandros Diamantidis
Hi all! The following question is off-topic, but I hope someone here
I was given some JPEG files that the GIMP opens fine, but Mozilla and
some image viewers can't display or give warnings about errors. It seems
KARE1.jpg: JPEG image data
dgrid.jpg: JPEG image data, JFIF standard 1.01
Is there a way to make them conform to JFIF without re-encoding?
I tried using the jpegtran tool, but it seems to write its output
in the same format as its input.
Thanks in advance, and my best wishes for the new year!
You might try jhead to copy EXIF information from one JPG to another. Jhead is
freely available software, and is availalble from:

http://www.sentex.net/~mwandel/jhead/
--
Michael Meissner
email: ***@the-meissners.org
http://www.the-meissners.org
Alexandros Diamantidis
2005-01-02 22:46:04 UTC
Permalink
Post by Michael Meissner
You might try jhead to copy EXIF information from one JPG to another. Jhead is
http://www.sentex.net/~mwandel/jhead/
Thanks for the suggestion. Indeed, this made the files JFIF compliant
according to file(1). Unfortunately, it didn't fix the problem. I
suppose my guess was wrong and there's some other irregularity.

Here's that file for anyone who wants to take a look. I'll leave it
up a couple of days...

Loading Image...

A strange thing I noticed in jhead's output: The picture is in colour -
what's with the "Black and white" line?

$ jhead -v KARE1.jpg
Jpeg section marker 0xed size 3944
Jpeg section marker 0xe2 size 11808
Jpeg section marker 0xee size 14
Jpeg section marker 0xdb size 132
JPEG image is 597w * 411h, 4 color components, 8 bits per sample
Jpeg section marker 0xdd size 4
Jpeg section marker 0xc4 size 418
File name : KARE1.jpg
File size : 114137 bytes
File date : 2004:12:29 05:49:34
Resolution : 597 x 411
Color/bw : Black and white
Jpeg process : Baseline
--
Alexandros Diamantidis * ***@hellug.gr
Manish Singh
2005-01-03 00:31:17 UTC
Permalink
Post by Alexandros Diamantidis
Post by Michael Meissner
You might try jhead to copy EXIF information from one JPG to another. Jhead is
http://www.sentex.net/~mwandel/jhead/
Thanks for the suggestion. Indeed, this made the files JFIF compliant
according to file(1). Unfortunately, it didn't fix the problem. I
suppose my guess was wrong and there's some other irregularity.
Here's that file for anyone who wants to take a look. I'll leave it
up a couple of days...
http://members.hellug.gr/adia/m/KARE1.jpg
A strange thing I noticed in jhead's output: The picture is in colour -
what's with the "Black and white" line?
Bug in jhead. See below.
Post by Alexandros Diamantidis
$ jhead -v KARE1.jpg
Jpeg section marker 0xed size 3944
Jpeg section marker 0xe2 size 11808
Jpeg section marker 0xee size 14
Jpeg section marker 0xdb size 132
JPEG image is 597w * 411h, 4 color components, 8 bits per sample
^^^^^^^^^^^^^^^^^^
What you have here is a Photoshop created CMYK JPEG, as opposed to the
much more commonly found RGB JPEG (with 3 color components). Most
programs don't handle CMYK JPEGs. GIMP's jpeg plugin does, as does
gdk-pixbuf's jpeg plugin, which is probably why it works in some other
image viewers you may have tried. It's a very simplistic conversion to
RGB, so the colors might be off for your image.

Mozilla's jpeg code doesn't handle it at all, and neither does Imlib.
Nor does jhead, as you noticed.

I doubt there is a way to convert the images to RGB losslessly. You
could resave them out in GIMP, or use ImageMagick's convert utility if
you have a lot of them.

-Yosh
Alexandros Diamantidis
2005-01-03 12:26:57 UTC
Permalink
Post by Manish Singh
What you have here is a Photoshop created CMYK JPEG, as opposed to the
much more commonly found RGB JPEG (with 3 color components). Most
[...]
Post by Manish Singh
I doubt there is a way to convert the images to RGB losslessly. You
could resave them out in GIMP, or use ImageMagick's convert utility if
you have a lot of them.
-Yosh
Thanks for pointing out what's going on. I converted them with
ImageMagick, and I'm keeping the originals as well.
--
Alexandros Diamantidis * ***@hellug.gr
Loading...