Board index » delphi » EXIF tags in JPEG files

EXIF tags in JPEG files


2005-04-03 03:32:41 AM
delphi4
I'm working on an app that modifies JPEG images, and I have the original
and modified images in two streams.
Is there a simple way to copy the EXIF info from the original to modified
file, without parsing the EXIF dictionaries? Something like...
1. Locate the relevant starting and ending markers in the 2 files; and
2. Merging the relevant bytes from the 1st stream into the 2nd.
I don't have ANY interest in the EXIF info; I just want to copy it, quickly
and easily.
One concern is whether this will result in broken pointers in the file (are
there any?).
TIA
Pete
 
 

Re:EXIF tags in JPEG files

Pete,
Quote
I'm working on an app that modifies JPEG images, and I have the original
and modified images in two streams.

Is there a simple way to copy the EXIF info from the original to modified
file, without parsing the EXIF dictionaries? Something like...

1. Locate the relevant starting and ending markers in the 2 files; and

2. Merging the relevant bytes from the 1st stream into the 2nd.

I don't have ANY interest in the EXIF info; I just want to copy it,
quickly
and easily.

One concern is whether this will result in broken pointers in the file
(are
there any?).
No, there are not. The following is from the top of my head, you may need to
check the specs to make sure it is completly correct.
A jpeg file is essentially a list of markers. Each marker starts with an $FF
byte. Next is a byte that identifies the particular marker. That byte is
different from $FF. If any $FF is needed in the actual data, it is replaced
by two subsequent $FF's. Thus, the jpeg looks like this:
any number of:
byte: $FF
byte: marker type identifier
any number of bytes, including any number of $FF $FF sequences
If you build a little code to parse jpegs, you will note that most start with
a fixed marker sequence. That is the JFIF sequence. Others will contain
EXIF, and another fixed marker sequence to start with. From that
observation, it should be feasable to build EXIF jpegs from JFIF sequence by
modifying the starter marker sequence, possibly throuwing around some makers
to do so, and insert the EXIF block in it.
Best regards,
Joris Van Damme
XXXX@XXXXX.COM
www.awaresystems.be/
Download your free TIFF tag viewer for windows here:
www.awaresystems.be/imaging/tiff/astifftagviewer.html
 

Re:EXIF tags in JPEG files

you can try dEXIF
mcguirez.homestead.com/downloads.html
--
Samson Fu
"Pete" <XXXX@XXXXX.COM>writes news:vj04mk53zbm7$XXXX@XXXXX.COM...
Quote

I'm working on an app that modifies JPEG images, and I have the original
and modified images in two streams.

Is there a simple way to copy the EXIF info from the original to modified
file, without parsing the EXIF dictionaries? Something like...

1. Locate the relevant starting and ending markers in the 2 files; and

2. Merging the relevant bytes from the 1st stream into the 2nd.

I don't have ANY interest in the EXIF info; I just want to copy it, quickly
and easily.

One concern is whether this will result in broken pointers in the file (are
there any?).

TIA

Pete
 

Re:EXIF tags in JPEG files

Thanks for the tips guys.
I'm making good progress, except for one thing that has me stumped.
The size of the EXIF info in files seems to be nonsense. For example, I
have a JPEG file where the EXIF info starts with
FF E1 35 70 E x i f 00 00 M M 00...
which means $3570 = 13680 bytes of data in the EXIF section. But this is
much too large. It takes you into the middle of the actual image data.
Other tags (e.g. JFIF) have the correct size.
What am I missing here?
Pete
 

Re:EXIF tags in JPEG files

On Wed, 6 Apr 2005 09:46:44 -0700, Pete writes:
Quote
The size of the EXIF info in files seems to be nonsense. For example, I
have a JPEG file where the EXIF info starts with

FF E1 35 70 E x i f 00 00 M M 00...

which means $3570 = 13680 bytes of data in the EXIF section. But this is
much too large. It takes you into the middle of the actual image data.

Other tags (e.g. JFIF) have the correct size.

What am I missing here?
Well, what I was missing is that the EXIF data often includes a thumbnail
image (before the main one), and this can consume a significant number of
bytes. The EXIF byte size is correct, and all's working fine.