ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Get all Exif data
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

Primus

10 Posts

Posted - Apr 13 2013 :  04:58:47  Show Profile  Reply
what is the best way to get all exif data from an image in an memo field?

w2m

USA
1990 Posts

Posted - Apr 13 2013 :  08:58:24  Show Profile  Reply
Are you referring to a database field? If so, probably you can get the exif only from a blob field, but I am not sure this is possible because I never have tried it.

William Miller
Email: w2m@frontiernet.net
EBook: http://www.imageen.com/ebook/
Apprehend: http://www.frontiernet.net/~w2m/index.html
Go to Top of Page

Primus

10 Posts

Posted - Apr 14 2013 :  23:38:32  Show Profile  Reply
no database! A simple memo field.
Go to Top of Page

xequte

39053 Posts

Posted - Apr 15 2013 :  02:43:45  Show Profile  Reply
It is quite easy. Please see the following demo in your ImageEn folder:

/Demos/InputOutput/EXIF/EXIF.dpr

You might also look at the functions in:

iexEXIFRoutines.pas



Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page

Primus

10 Posts

Posted - Apr 15 2013 :  04:03:06  Show Profile  Reply
I want to display only exif fields with data and no emtpy fields.
thats many work to display all data. in the sample are not all exifdata. Can i use the io.EXIF_Tags lists with a memo or grid?
Go to Top of Page

w2m

USA
1990 Posts

Posted - Apr 15 2013 :  10:20:13  Show Profile  Reply
Not all cameras fill in all the EXIF fields. In fact most do not fill all the fields. If the field is empty then you have to write code to fill the memo with an appropriate caption to show that the field is empty.

William Miller
Go to Top of Page

xequte

39053 Posts

Posted - Apr 15 2013 :  16:41:16  Show Profile  Reply
Hi

You can do it as follows:

uses
  iexExifRoutines;


...
  Memo1.clear;

  ImageEnIO1.ParamsFromFile(sFilename); // Don't need to call this if the image has already been loaded, e.g. ImageEnView1.IO.LoadFromFile()

  if ImageEnIO1.Params.EXIF_HasEXIFData = false then
  begin
    Memo1.Lines.add('No EXIF Data');
    exit;
  end;

  for i := low(EXIF) to high(EXIF) do
  begin
    sValue := GetEXIFField(ImageEnIO1, i);
    if sValue <> '' then
      Memo1.Lines.Add(EXIF[i].Description + ': ' + sValue);
  end;

...


Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page

Primus

10 Posts

Posted - Apr 15 2013 :  23:34:40  Show Profile  Reply
Great! Many thanks!
Go to Top of Page

Primus

10 Posts

Posted - Apr 15 2013 :  23:48:26  Show Profile  Reply
But how do i declare EXIF ??
Go to Top of Page

w2m

USA
1990 Posts

Posted - Apr 16 2013 :  08:04:59  Show Profile  Reply
You do not have to define it. It is defined in iexEXIFRoutines. Just add iexEXIFRoutines to uses.

William Miller
Email: w2m@frontiernet.net
EBook: http://www.imageen.com/ebook/
Apprehend: http://www.frontiernet.net/~w2m/index.html
Go to Top of Page

Primus

10 Posts

Posted - Apr 17 2013 :  02:02:35  Show Profile  Reply
i have iexEXIFRoutines in the uses clausel.
GetEXIFField works fine.
only the EXIF const not work: undeclared identifier EXIF
Go to Top of Page

w2m

USA
1990 Posts

Posted - Apr 17 2013 :  07:22:05  Show Profile  Reply
Post your code or we can not help.

William Miller
Adirondack Software & Graphics
Email: w2m@frontiernet.net
EBook: http://www.imageen.com/ebook/
Apprehend: http://www.frontiernet.net/~w2m/index.html
Go to Top of Page

Primus

10 Posts

Posted - Apr 17 2013 :  08:23:25  Show Profile  Reply
ok, here is the code:
unit Unit3;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, imageenio, ieview,
  imageenview, imageen, iexExifRoutines;

type
  TForm3 = class(TForm)
    ImageEnIO1: TImageEnIO;
    Button1: TButton;
    ImageEn1: TImageEn;
    Memo1: TMemo;
    procedure Button1Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form3: TForm3;

implementation

{$R *.dfm}

procedure TForm3.Button1Click(Sender: TObject);
var
svalue : String;
i : Integer;
begin
  imageenio1.loadfromfile('.\1.jpg');
  Memo1.clear;

  ImageEnIO1.ParamsFromFile('.\1.jpg'); // Don't need to call this if the image has already been loaded, e.g. ImageEnView1.IO.LoadFromFile()

  if ImageEnIO1.Params.EXIF_HasEXIFData = false then
  begin
    Memo1.Lines.add('No EXIF Data');
    exit;
  end;
  for i := low(EXIF) to high(EXIF) do
  begin
    sValue := GetEXIFField(ImageEnIO1, i);
    if sValue <> '' then
      Memo1.Lines.Add(EXIF[i].Description + ': ' + sValue);
  end;

end;

end.


DCC ERROR unit3.pas(46) E2003 undclared identifier 'EXIF'
Go to Top of Page

w2m

USA
1990 Posts

Posted - Apr 17 2013 :  10:00:38  Show Profile  Reply
You do not have to call ImageEnIO1.LoadFromFile('.\1.jpg')
followed by ImageEnIO1.ParamsFromFile('.\1.jpg');. It is not necessary or wise to do.

I was mistaken.... Even though you have iexEXIFRoutines in uses you have to take the types and const from iexEXIFRoutines and paste them into your unit.

If you used a stringgrid, instead of a memo there are functions in iexEXIFRoutines that fills the grid with EXIF parameters and the image's EXIF values for you with 2 lines of code.

This code was compiled and tested with Delphi 2010. In any event here is the code to fill a TMemo with EXIF info:

unit Unit1;

interface

uses
  WinApi.Windows, WinApi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms,
  Vcl.Dialogs, Vcl.StdCtrls, imageenio, Vcl.ExtDlgs, Vcl.Jpeg;

type

  EXIF_Item = record
  private
  public
    Description: string;
    VarType: Integer;
    Editable: boolean;
  end;

  TForm1 = class(TForm)
    OpenPictureDialog1: TOpenPictureDialog;
    ImageEnIO1: TImageEnIO;
    Memo1: TMemo;
    Open: TButton;
    procedure OpenClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

uses iexEXIFRoutines;

{$R *.dfm}

resourcestring

  // EXIF Data
  s_UserComment = 'User Comment';
  s_Description = 'Description';
  s_Camera = 'Camera';
  s_Orientation = 'Camera Orientation';
  s_Inch = 'Inch';
  s_CM = 'cm';
  s_XResolution = 'Horizontal Resolution';
  s_Yresolution = 'Vertical Resolution';
  s_DateTime = 'Date and Time';
  s_DateTimeOriginal = 'Original Date and Time';
  s_DateTimeDigitized = 'Digitized Date and Time';
  s_Copyright = 'Copyright';
  s_ExposureTime = 'Exposure Time';
  s_FNumber = 'F-Stop';
  s_ExposureProgram = 'Exposure Program';
  s_ManualControl = 'Manual';
  s_ProgramNormal = 'Normal';
  s_AperturePriority = 'Aperture Priority';
  s_ShutterPriority = 'Shutter Priority';
  s_CreativeProgram  = 'Creative Program';
  s_ActionProgram = 'Action Program';
  s_Portraitmode = 'Portrait Mode';
  s_LandscapeMode = 'Landscape Mode';
  s_CompressedBitsPerPixel = 'Compression Ratio';
  s_ShutterSpeedValue = 'Shutter Speed';
  s_ApertureValue = 'Aperture Value';
  s_ISOSpeedRatings = 'ISO Speed Rating';
  s_BrightnessValue = 'Brightness';
  s_ExposureBiasValue = 'Exposure Compensation';
  s_MaxApertureValue = 'Max Aperture Value';
  s_SubjectDistance = 'Subject Distance';
  s_MeteringMode = 'Metering Mode';
  s_average = 'Average';
  s_CenterWeightedAverage = 'Center-weighted Average';
  s_Spot = 'Spot';
  s_MultiSpot = 'Multi-Spot';
  s_MultiSegment = 'Multi-Segment';
  s_partial = 'Partial';
  s_WhiteBalance = 'Lighting';
  s_daylight = 'Daylight';
  s_fluorescent = 'Flourescent';
  s_tungsten = 'Tungsten';
  s_flash = 'Flash';
  s_standardLightA = 'Standard Light A';
  s_standardLightB = ' Standard Light B';
  s_standardLightC = ' Standard Light C';
  s_D55 = 'D55';
  s_D65 = 'D65';
  s_D75 = 'D75';
  s_FlashDidNotFire = 'Not Used';
  s_flashFired = 'Fired';
  s_flashFiredNoStrobeLight = 'Fired, No Strobe Return';
  s_flashFiredStrobeLight = 'Fired, with Strobe Return';
  s_FocalLength = 'Focal Length';
  s_FlashPixVersion = 'FlashPix Version';
  s_ColorSpace = 'Color Space';
  s_RGB = 'RGB';
  s_Uncalibrated = 'Uncalibrated';
  s_ExifImageWidth = 'Image Width';
  s_ExifImageHeight = 'Image Height';
  s_RelatedSoundFile = 'Sound File';
  s_FocalPlaneXResolution = 'Focal Plane Horz. Resolution';
  s_FocalPlaneYResolution = 'Focal Plane Vert. Resolution';
  s_ExposureIndex = 'Exposure Index';
  s_SensingMethod = 'Sensing Method';
  s_OneChipColorAreaSensor = 'Single Chip Color Area';
  s_UnknownMethod = 'Unknown Method';
  s_FileSource = 'File Source';
  s_DigitalStillCamera = 'Digital Still Camera';
  s_UnknownDevice = 'Unknown Device';
  s_SceneType = 'Scene Type';
  s_DirectlyPhotographed = 'Directly Photographed';
  s_YcbCrPositioning = 'Chroma Sample Point';
  s_Centered = 'Centered';
  s_DataPoint = 'Data Point';
  s_Seconds = 'Seconds';
  s_Second = 'Second';
  s_EXIFOrientation1 = 'Orientated Correctly';
  s_EXIFOrientation2 = 'Horizontally Flipped';
  s_EXIFOrientation3 = 'Offset by 180°';
  s_EXIFOrientation4 = 'Vertically Flipped';
  s_EXIFOrientation5 = 'Flipped Horiz. and Offset 90° CCW';
  s_EXIFOrientation6 = 'Offset by 90° CCW';
  s_EXIFOrientation7 = 'Flipped Horiz. and Offset 90° CW';
  s_EXIFOrientation8 = 'Offset by 90° Clockwise';

  s_ExposureMode          = 'Exposure Mode';
  s_DigitalZoomRatio      = 'Digital Zoom Ratio';
  s_FocalLengthIn35mmFilm = 'Focal Length in 35mm Film';
  s_SceneCaptureType      = 'Scene Capture Type';
  s_GainControl           = 'Gain Control';
  s_Contrast              = 'Contrast';
  s_Saturation            = 'Saturation';
  s_Sharpness             = 'Sharpness';
  s_SubjectDistanceRange  = 'Subject Distance';
  s_GPSLatitude           = 'GPS Latitude';        // Degrees
  s_GPSLongitude          = 'GPS Longitude';       // Degrees
  s_GPSAltitude           = 'GPS Altitude';
  s_GPSImageDirection     = 'GPS Image Direction';
  s_GPSTrack              = 'GPS Movement Direction';
  s_GPSSpeed              = 'GPS Movement Speed';
  s_GPSDateAndTime        = 'GPS Date and Time';
  s_GPSSatellites         = 'GPS Satellites';
  s_GPSVersionID          = 'GPS Version';

  s_AutoExposure      = 'Auto exposure';
  s_ManualExposure    = 'Manual exposure';
  s_AutoBracket       = 'Auto bracket';

  s_Autowhitebalance = 'Auto white balance';
  s_Manualwhitebalance       = 'Manual white balance';

  s_Standard       = 'Standard';
  s_Landscape      = 'Landscape';
  s_Portrait       = 'Portrait';
  s_NightScene    = 'Night scene';

  s_None   = 'None';
  s_LowGainup    = 'Low gain up';
  s_HighGainup   = 'High gain up';
  s_LowGaindown  = 'Low gain down';
  s_HighGaindown = 'High gain down';

  s_Normal = 'Normal';
  s_Soft   = 'Soft';
  s_Hard   = 'Hard';

  s_LowSaturation = 'Low saturation';
  s_HighSaturation        = 'High saturation';

  s_Macro  = 'Macro';
  s_CloseView     = 'Close view';
  s_DistantView   = 'Distant view';

  s_Artist         =  'Artist';
  s_XPTitle        =  'Title (Windows)';
  s_XPComment      =  'Comment (Windows)';
  s_XPAuthor       =  'Author (Windows)';
  s_XPKeywords     =  'Keywords (Windows)';
  s_XPSubject      =  'Subject (Windows)';
  s_XPRating       =  'Rating (Windows)';

const
  _vString=1;
  _vInteger=2;
  _vDouble=3;
  Maybe=false;

  EXIF: array[0.._EXIF_Tag_Count - 1] of EXIF_Item = (
    (Description: s_UserComment; VarType: _vString; Editable: TRUE), // _EXIF_UserComment=0;
    (Description: s_Description; VarType: _vString; Editable: TRUE), // _EXIF_ImageDescription=1;
    (Description: s_Camera; VarType: _vString; Editable: TRUE), // _EXIF_Camera
    (Description: s_XResolution; VarType: _vDouble; Editable: FALSE), // _EXIF_XResolution=4;
    (Description: s_YResolution; VarType: _vDouble; Editable: FALSE), // _EXIF_YResolution=5;
    (Description: s_DateTime; VarType: _vString; Editable: TRUE), // _EXIF_DateTime=7;
    (Description: s_DateTimeOriginal; VarType: _vString; Editable: TRUE),
      // _EXIF_DateTimeOriginal=8;
    (Description: s_DateTimeDigitized; VarType: _vString; Editable: TRUE),
      // _EXIF_DateTimeDigitized=9;
    (Description: s_Copyright; VarType: _vString; Editable: TRUE), // _EXIF_Copyright=10;
    (Description: s_Orientation; VarType: _vInteger; Editable: FALSE), // _EXIF_Orientation=11;
    (Description: s_ExposureTime; VarType: _vDouble; Editable: Maybe), // _EXIF_ExposureTime=12;
    (Description: s_FNumber; VarType: _vDouble; Editable: Maybe), // _EXIF_FNumber=13;
    (Description: s_ExposureProgram; VarType: _vInteger; Editable: Maybe),
      // _EXIF_ExposureProgram=14;
    (Description: s_ISOSpeedRatings; VarType: _vInteger; Editable: Maybe),
      // _EXIF_ISOSpeedRatings[index=15;
    (Description: s_ShutterSpeedValue; VarType: _vDouble; Editable: Maybe),
      // _EXIF_ShutterSpeedValue=17;
    (Description: s_ApertureValue; VarType: _vDouble; Editable: Maybe), // _EXIF_ApertureValue=18;
    (Description: s_BrightnessValue; VarType: _vDouble; Editable: Maybe),
      // _EXIF_BrightnessValue=19;
    (Description: s_ExposureBiasValue; VarType: _vDouble; Editable: Maybe),
      // _EXIF_ExposureBiasValue=20;
    (Description: s_MaxApertureValue; VarType: _vDouble; Editable: Maybe),
      // _EXIF_MaxApertureValue=21;
    (Description: s_SubjectDistance; VarType: _vDouble; Editable: Maybe),
      // _EXIF_SubjectDistance=22;
    (Description: s_MeteringMode; VarType: _vInteger; Editable: FALSE), // _EXIF_MeteringMode=23;
    (Description: s_WhiteBalance; VarType: _vInteger; Editable: FALSE), // _EXIF_LightSource=24;
    (Description: s_Flash; VarType: _vInteger; Editable: FALSE), // _EXIF_Flash=25;
    (Description: s_FocalLength; VarType: _vDouble; Editable: TRUE), // _EXIF_FocalLength=26;
    (Description: s_FlashPixVersion; VarType: _vString; Editable: TRUE),
      // _EXIF_FlashPixVersion=27;
    (Description: s_ColorSpace; VarType: _vInteger; Editable: FALSE), // _EXIF_ColorSpace=28;
    (Description: s_ExifImageWidth; VarType: _vInteger; Editable: TRUE), // _EXIF_ExifImageWidth=29;
    (Description: s_ExifImageHeight; VarType: _vInteger; Editable: TRUE),
      // _EXIF_ExifImageHeight=30;
    (Description: s_RelatedSoundFile; VarType: _vString; Editable: TRUE),
      // _EXIF_RelatedSoundFile=31;
    (Description: s_FocalPlaneXResolution; VarType: _vDouble; Editable: FALSE),
      // _EXIF_FocalPlaneXResolution=32;
    (Description: s_FocalPlaneYResolution; VarType: _vDouble; Editable: FALSE),
      // _EXIF_FocalPlaneYResolution=33;
    (Description: s_ExposureIndex; VarType: _vDouble; Editable: TRUE), // _EXIF_ExposureIndex=34;
    (Description: s_SensingMethod; VarType: _vInteger; Editable: FALSE), // _EXIF_SensingMethod=35;
    (Description: s_FileSource; VarType: _vInteger; Editable: FALSE), // _EXIF_FileSource=36;
    (Description: s_SceneType; VarType: _vInteger; Editable: FALSE), // _EXIF_SceneType=37;
    (Description: s_YCbCrPositioning; VarType: _vInteger; Editable: FALSE),
      // _EXIF_YCbCrPositioning=38;
    (Description: s_ExposureMode; VarType: _vInteger; Editable: FALSE),
      // _EXIF_ExposureMode            = 39;
    (Description: s_WhiteBalance; VarType: _vInteger; Editable: FALSE),
      // _EXIF_WhiteBalance            = 40;
    (Description: s_DigitalZoomRatio; VarType: _vDouble; Editable: Maybe),
      // _EXIF_DigitalZoomRatio        = 41;
    (Description: s_FocalLengthIn35mmFilm; VarType: _vInteger; Editable: Maybe),
      // _EXIF_FocalLengthIn35mmFilm   = 42;
    (Description: s_SceneCaptureType; VarType: _vInteger; Editable: FALSE),
      // _EXIF_SceneCaptureType        = 43;
    (Description: s_GainControl; VarType: _vInteger; Editable: FALSE),
      // _EXIF_GainControl             = 44;
    (Description: s_Contrast; VarType: _vInteger; Editable: FALSE),
      // _EXIF_Contrast                = 45;
    (Description: s_Saturation; VarType: _vInteger; Editable: FALSE),
      // _EXIF_Saturation              = 46;
    (Description: s_Sharpness; VarType: _vInteger; Editable: FALSE),
      // _EXIF_Sharpness               = 47;
    (Description: s_SubjectDistanceRange; VarType: _vInteger; Editable: FALSE),
      // _EXIF_SubjectDistanceRange    = 48;
    (Description: s_GPSLatitude; VarType: _vDouble; Editable: FALSE),
      // _EXIF_GPSLatitudeDegrees      = 49;
    (Description: s_GPSLongitude; VarType: _vDouble; Editable: FALSE),
      // _EXIF_GPSLongitudeDegrees     = 50;

    (Description: s_GPSAltitude; VarType: _vDouble; Editable: FALSE), // _EXIF_GPSAltitude
    (Description: s_GPSImageDirection; VarType: _vDouble; Editable: FALSE),
      // _EXIF_GPSImageDirection
    (Description: s_GPSTrack; VarType: _vDouble; Editable: FALSE), // _EXIF_GPSTrack
    (Description: s_GPSSpeed; VarType: _vDouble; Editable: FALSE), // _EXIF_GPSSpeed
    (Description: s_GPSDateAndTime; VarType: _vDouble; Editable: FALSE), // _EXIF_GPSDateAndTime
    (Description: s_GPSSatellites; VarType: _vString; Editable: TRUE), // _EXIF_GPSSatellites
    (Description: s_GPSVersionID; VarType: _vString; Editable: TRUE), // _EXIF_GPSVersionID

    (Description: s_Artist; VarType: _vString; Editable: True), // _EXIF_Artist
    (Description: s_XPTitle; VarType: _vString; Editable: TRUE), // _EXIF_XPTitle
    (Description: s_XPComment; VarType: _vString; Editable: TRUE), // _EXIF_XPComment
    (Description: s_XPAuthor; VarType: _vString; Editable: TRUE), // _EXIF_XPAuthor
    (Description: s_XPKeywords; VarType: _vString; Editable: TRUE), // _EXIF_XPKeywords
    (Description: s_XPSubject; VarType: _vString; Editable: TRUE), // _EXIF_XPSubject
    (Description: s_XPRating; VarType: _vInteger; Editable: TRUE) // _EXIF_XPRating
    );

procedure TForm1.OpenClick(Sender: TObject);
var
  i: Integer;
  svalue: string;
begin
  if OpenPictureDialog1.Execute then
    if FileExists(OpenPictureDialog1.FileName) then
    begin
      ImageEnIO1.LoadFromFile(OpenPictureDialog1.FileName);
      Memo1.Clear;

      if ImageEnIO1.Params.EXIF_HasEXIFData = false then
      begin
        Memo1.Lines.add('No EXIF Data');
        exit;
      end;

      for i := low(EXIF) to high(EXIF) do
      begin
        sValue := GetEXIFField(ImageEnIO1, i);
        if sValue <> '' then
          Memo1.Lines.Add(EXIF[i].Description + ': ' + sValue);
      end;
    end;
end;

end.


William Miller
Adirondack Software & Graphics
Email: w2m@frontiernet.net
EBook: http://www.imageen.com/ebook/
Apprehend: http://www.frontiernet.net/~w2m/index.html
Go to Top of Page

Primus

10 Posts

Posted - Apr 18 2013 :  00:42:26  Show Profile  Reply
now it works fine
Many many thanks!!
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: