Jpeg Info

In the spirit of helping I’m trying to post old articles again in on my website. Links below does not work, but here is the text about my Jpeg /Exif “investigations” 9 years ago 🙂


Recently someone asked me for a program to rename jpeg files, so they would contain the date as a part of the file name. Naive as I am, I thought that this would be an easy task, so I offered to help. I just didn’t know if he wanted to use the file date or the “current date” when attaching the date to the file name.

To my supprise he told me that some programs could read the date when the pictures actually were taken. I didn’t want to tell him that I had no clue about how images are stored, so I just answere something vague like “I’ll take a look”.

I stated to search the web for tags like “Jpeg date” etc., but they didn’t give me much result. I started to look into the file and search for the first bytes (as hex) in the file. Fast I find some matches on FFD8FFE0, but the file I got as an example started with FFD8FFE1.

0000: FFD8DDE1 15484578 69660000 49492A00 | ÿØÿá.HExif..II*.
0010: 08000000 0B000E01 02001500 00009200 | ................

First 32 bytes of a jpeg file

Further looking into the example file, and some “generic” jpeg files, show that the files from a digital camera is quite different. Where my own jpeg files all contain the string JFIF, then the jpeg file from a digital camera contain the string Exif.

I find that Exif stands for “Exchangeable Image File” and that it’s a JEIDA (Japan Electronic Industry Development Association) standard. Since most (all?) browsers actually can read these images I expect this format to be conform with the normal Jpeg format. There a homepage called www.exif.org dedicated to describing the Exif format. You can read more about exif on wikipedia

So reading into the Exif standard shows that it’s not really all that difficult and that you can read more out of an image that you think!

I got the picture below as a reference, nice picture, but I converted it to something small for display here – the image info is still intact though.
Image with the Exif information below

Image with the Exif information below

From this picture, I sucessfully extracted the date it was taken (my job), but I also found information like what camera and what software version it had … kind of interresting isn’t it?

C:\Temp>jpegdate /i dsc00154.jpg
Information for: dsc00154.jpg
             ImageDescription: SANYO DIGITAL CAMERA
                         Make: SANYO Electric Co.,Ltd.
                        Model: SR662
                  Orientation: 1
                  XResolution: 72/1
                  YResolution: 72/1
               ResolutionUnit: 2
                     Software: V662U-71
                     DateTime: 2001:09:15 18:11:27
             YCbCrPositioning: 2
                 ExposureTime: 1/4
                      FNumber: 28/10
                  ExifVersion: 30 32 30 30
             DateTimeOriginal: 2001:09:15 18:11:27
            DateTimeDigitized: 2001:09:15 18:11:27
      ComponentsConfiguration: 01 02 03 00
       CompressedBitsPerPixel: 35/10
            ExposureBiasValue: 0/10
             MaxApertureValue: 3/1
                 MeteringMode: 5
                  LightSource: 0
                        Flash: 0
                  FocalLength: 60/10
                    MakerNote: 53 41 4E 59 4F 00 01 00 03 00 00 02 04 00 03 00
                             : 00 00 12 03 00 00 01 02 03 00 01 00 00 00 04 00
                             : 00 00 00 0F 04 00 14 00 00 00 1E 03 00 00 00 00
                             : 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01
                             : 04 AD 00 00 0E 5F 00 01 E8 48 00 00 07 CE 00 00
                             : 00 00 00 00 00 00 00 00 00 00 00 00 03 61 48 F1
                             : 3D 25 00 03 69 0C 17 A9 17 A9 00 00 00 00 00 00
                             : 00 00 00 00 00 00 00 0E 00 13 00 00 00 20 00 84
                             : 00 69 00 84 00 69 00 00 00 51 00 00 00 00
              FlashPixVersion: 30 31 30 30
                   ColorSpace: 65535
              PixelXDimension: 1024
              PixelYDimension: 768
              PixelYDimension: 768
                   FileSource: 03
                  Compression: 6
                  XResolution: 72/1
                  YResolution: 72/1
               ResolutionUnit: 2
        JPEGInterchangeFormat: 878
  JPEGInterchangeFormatLength: 4562

Some of the fields contained in an Exif Jpeg image

So how did I do this? First of all I usually use Delphi because of .. hmm .. I don’t know why – I just use to use Delphi.. Anyway you can find the code here : JpegDate.dpr. You will see that it’s a CONSOLE program, with two units for reading a file stream
(mdFileStream.pas) and for reading the Exif information from the Jpeg file (mdJpegInfo.pas). Both the units are written
for this project, but they should be “kind of” generic <smile>.

If you have Delphi, you can download the full code here: JpegDate14src.zip, or if you just would like the program, it’s also available for download: JpegDate14.zip.

So, now I hope you got a bit of insight into the Exif format and into what you can expect to find inside your pictures … yes there is more, but it’s not related to date and time ….

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.