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

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Setting EXIF date/time stamp

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
troberts Posted - Jun 13 2022 : 02:20:00
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?
2   L A T E S T    R E P L I E S    (Newest First)
troberts Posted - Jun 13 2022 : 23:22:05
Great, everything is working now. Thanks for your help Nigel.
xequte Posted - Jun 13 2022 : 20:24:11
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