Code Monkey home page Code Monkey logo

ccr-exif's Introduction

CCR Exif is a Delphi library to read and write Exif, IPTC and XMP metadata from JPEG, TIFF and PSD images. Requires Delphi 2006 or later to compile, preferably Delphi 2007 or later. Also works with Win64 or OS X targets in Delphi XE2+, though not XE2/iOS because FPC is not supported.

Important - due to difficulties in supporting both the VCL TJpegImage and the FMX TBitmap in the same unit, use in a FireMonkey project requires manually setting a FMX conditional define at the project level. Further, for mobile, only XE5 is supported, and only with Andreas Hausladen's string types patch applied.

Example 1: reading the camera make and model tags from an image's Exif metadata:

uses
  CCR.Exif;

procedure ReadCameraMakeAndModel(const FileName: string; out Make, Model: string);
var
  ExifData: TExifData;
begin
  ExifData := TExifData.Create;
  try
    ExifData.LoadFromGraphic(FileName); //LoadFromJPEG before v1.5.0   
    Make  := ExifData.CameraMake;  //returns an empty string if tag doesn't exist
    Model := ExifData.CameraModel; //ditto
  finally
    ExifData.Free;
  end;
end;

Example 2: setting some Exif tags:

uses
  CCR.Exif;

procedure SetSomeExifTags(const FileName: string);
var
  ExifData: TExifData;
begin
  ExifData := TExifData.Create;
  try
    ExifData.LoadFromGraphic(FileName);
    ExifData.Subject := 'Wimbledon Tennis';
    ExifData.SetKeyWords(['tennis', 'Wimbledon', 'match', 'SW19']);
    //Exif uses the degrees/minutes/seconds GPS format
    ExifData.GPSLatitude.Assign(51, 26, 1.48, ltNorth);
    ExifData.GPSLongitude.Assign(0, 12, 50.63, lnWest);
    ExifData.SaveToGraphic(FileName); 
  finally
    ExifData.Free;
  end;
end;

Example 3: setting the 'headline' and 'credit' IPTC tags:

uses
  CCR.Exif.IPTC;

procedure SetIPTCHeadlineAndCredit(const FileName,
  NewHeadline, NewCredit: string);
var
  IPTCData: TIPTCData;
begin
  IPTCData := TIPTCData.Create;
  try
    IPTCData.LoadFromGraphic(FileName);
    IPTCData.Headline := NewHeadline;
    IPTCData.Credit := NewCredit;
    IPTCData.SaveToGraphic(FileName);
  finally
    IPTCData.Free;
  end;
end;

For more information about the API, please refer to the included PDF, available here. A small set of console and GUI demos is also included with the main source.

ccr-exif's People

Contributors

chrisrolliston avatar ppm0 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.