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
 Setting EXIF date/time stamp
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

troberts

New Zealand
3 Posts

Posted - Jun 13 2022 :  02:20:00  Show Profile  Reply
Hi,

I am trying to write a method which sets the date/time stamp of a given JPG file. This is what I have so far:

procedure TFrmSetDate.SetDateTimeForFile(AFileName: string; ADateTime: TDateTime);
var
  ImageEnView: TImageEnView;
begin
  ImageEnView := TImageEnView.Create(nil);
  try
    ImageEnView.IO.LoadFromFile(AFileName);
    ImageEnView.IO.Params.EXIF_DateTime2 := ADateTime;
    ImageEnView.IO.Params.EXIF_DateTimeOriginal2 := ADateTime;
    ImageEnView.IO.SaveToFile(AFileName);
  finally
    ImageEnView.Free;
  end;
end;


First question: this doesn't appear to work. The new date and time are not written to the file. What am I doing wrong?

Second question: after running this method, the updated file is about 1/3 of its original size. Why is this and how can I update the file so that it is unchanged other than the date and time?

xequte

7022 Posts

Posted - Jun 13 2022 :  20:24:11  Show Profile  Reply
Hi

1. Ensure that you enable EXIF_HasExifData so ImageEn knows that you have exif data.

https://www.imageen.com/help/TIOParams.EXIF_HasEXIFData.html


2. This is due to resaving (i.e. recompressing of the JPEG), so use InjectJpegEXIF() to avoid it

https://www.imageen.com/help/TImageEnIO.InjectJpegEXIF.html


Examples

// Update the GPS EXIF data in a file
io := TImageEnIO.create(nil);
try
  io.ParamsFromFile( FilenameStr );

  io.Params.EXIF_GPSLatitude  := GPSLatitudeFloat;
  io.Params.EXIF_GPSLongitude := GPSLongitudeFloat;
  io.Params.EXIF_GPSVersionID := GPS_Version_ID;
  io.Params.EXIF_HasEXIFData  := True;

  io.InjectJpegEXIF( FilenameStr );
finally
  io.Free;
end;

// Update EXIF date for the current file
ImageEnView1.IO.Params.EXIF_DateTime2 := Now;
ImageEnView1.IO.Params.EXIF_DateTimeOriginal2 := Now;
ImageEnView1.IO.Params.EXIF_HasEXIFData  := True;
ImageEnView1.IO.InjectJpegEXIF( ImageEnView1.IO.Params.Filename );


Nigel
Xequte Software
www.imageen.com
Go to Top of Page

troberts

New Zealand
3 Posts

Posted - Jun 13 2022 :  23:22:05  Show Profile  Reply
Great, everything is working now. Thanks for your help Nigel.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: