Lazarus

Programming => Packages and Libraries => Topic started by: Romain on April 26, 2019, 10:24:39 am

Title: FPExif duplicates value for DTOrig
Post by: Romain on April 26, 2019, 10:24:39 am
Hi,

I use FPExif library [r6842] with Lazarus 2.0.2

Whenever I try to modify the DTOrig EXIF value, the value gets changed but appended twice.

For example, if I want to set the value to 2019:04:26 10:16:16, it gets written as string 2019:04:26 10:16:162019:04:26 10:16:16 ( see screenshot below )

Here is an extract of the code I use :

Code: Pascal  [Select]
  1.  L_ImageInfo := TImgInfo.Create;
  2.  
  3.   try
  4.     L_ImageInfo.LoadFromFile(F_FullName);
  5.     if L_ImageInfo.ExifData <> nil then
  6.     begin
  7.  
  8.       L_Tag := L_ImageInfo.ExifData.TagByName['DateTimeOriginal'];
  9.       if L_Tag <> nil then
  10.         TDateTimeTag(L_Tag).AsDateTime := F_NewPhotoDT;
  11.  
  12.       L_Tag := L_ImageInfo.ExifData.TagByName['DateTimeDigitized'];
  13.       if L_Tag <> nil then
  14.         TDateTimeTag(L_Tag).AsDateTime := F_NewPhotoDT;
  15.  
  16.       L_Tag := L_ImageInfo.ExifData.TagByName['DateTime'];
  17.       if L_Tag <> nil then
  18.         TDateTimeTag(L_Tag).AsDateTime := F_NewPhotoDT;
  19.  
  20.       try
  21.         L_ImageInfo.SaveToFile(F_FullName);
  22.  
  23.       except
  24.          ....
  25.       end;
  26.  
  27.  

Best regards,
Romain
Title: Re: FPExif duplicates value for DTOrig
Post by: wp on April 26, 2019, 10:32:30 am
Which program are you using to display the exif fields in the screenshot?
Title: Re: FPExif duplicates value for DTOrig
Post by: Romain on April 26, 2019, 10:38:49 am
Sorry, forget to mention : NirSoft ExifDataView

http://www.nirsoft.net/utils/exif_data_view.html (http://www.nirsoft.net/utils/exif_data_view.html)

Romain
Title: Re: FPExif duplicates value for DTOrig
Post by: wp on April 26, 2019, 12:28:49 pm
No, the date is not duplicated, NirSoft erroneously displays here the text fields of two different date/time tags having the same values ("Date Time Original" and "Date Time Digitized") which immediately follow each other in the file. Look at the "Value Length" column of 19 which gives only the first date, and when you click on the "DTOrig" row the hex viewer will also display only a single date.

Nevertheless, there is an issue with fpexif which does not write a trailing NULL byte after each string. NirSoft's ExifDataView seems to ignore the explicit length specification and seeks a trailing NULL byte after the date/time string. I looked into the EXIF specification and it clearly says for tag type 2 "ASCII An 8-bit byte containing one 7-bit ASCII code. The final byte is terminated with NULL."

The new fpexif revision on CCR does write a NULL byte, and NirSoft's viewer displays a single date now.
Title: Re: FPExif duplicates value for DTOrig
Post by: Romain on April 26, 2019, 01:15:44 pm
Many thanks for the information, your great support and fixing the issue !

It works fine now. Keep up the excellent work.

Best regards,
Romain