Reading the Exif and IPTC information from a JPEG image with Delphi

Most of you know about my passion with photography and these days I've been working on a new project setting up my own photographic web gallery. I know that I've been more focused on photography than programming, but it's one of my hobbies and after doing some courses I can say that I really enjoy it!. Anyway, going on with my passion, I started the gallery with Flash and XML, and the big problem here was the modification of all the pictures. This tedious task let me build a set of applications to increase speed and productivity while I was uploading the pictures into the web. I started creating Thundax Batch Watermark, a very powerful tool that let you add a watermark to your pictures. Then, few days ago, I released the Thundax Image Resizer to built the resized image with its thumbnail, and finally the Thundax Exif Information to obtain all the Exif (Exchangeable image file format) information contained into the picture with all the information about the camera, exposure time, focal length, etc.
This information is contained into the Resume section of the file:

And I've been struggling in how to get that with Delphi. After a few hours of research, I found the CCR Exif Library for Delphi, a very simple and powerful library for reading Exif and IPTC information. Now with my application we can get the most important information and use it to publish your work:
The library is very easy to use and with a very little lines of code we can extract all the information we want and present it in the desired format.
The code looks like this:
procedure TForm1.ListView1Click(Sender: TObject);
var
  ExifData: TExifData;
  JPEGFile : string;
begin
    if ListView1.ItemIndex = -1 then
        Exit;
    ExifData := nil;
    imgThumbnail.Picture.Assign(nil);
    Memo1.Clear;
    JPEGFile := ListView1.Items[ListView1.ItemIndex].Caption;
    try
        ExifData := TExifData.Create;
        ExifData.EnsureEnumsInRange := False; 
        ExifData.LoadFromJPEG(JPEGFile);
        if ExifData.Empty then
            Memo1.lines.Add('No Exif metadata found')
        else
            LoadStandardValues(ExifData);

      if imgThumbnail.Picture.Graphic <> nil then
      begin
        grpThumbnail.Width := (grpThumbnail.Width - imgThumbnail.Width) +
          imgThumbnail.Picture.Width;
        grpThumbnail.Visible := True;
      end;
    finally
        ExifData.Free;
    end;
end;

Now we can publish our pictures with all the camera information like this:

Camera model: PENTAX K10D       

Date/time: 03/01/2009 17:55:05

Resolution: 72 x 72 inches

Exposure time: 0,3 seconds

F number: F/4

Focal length: 28,13 mm

ISO speed rating(s): 400


You can find more information about this in the following links:

Comments

Popular Posts