Recent

Author Topic: FPexif-package Retrieve all exif-info ?  (Read 5748 times)

WimVan

  • Jr. Member
  • **
  • Posts: 85
FPexif-package Retrieve all exif-info ?
« on: January 23, 2019, 08:51:42 am »
As photographer, I'm always interested in info which is kept in the exif-part of an image, film.
Normally I'm using a process and EXIFtool to retrieve this kind of information.
This procedure is huge because you have to run a command with several parameters.  Each time you run it, a popup-windows appears and closes ... and finally you have to treat the returned info.
This is very tricky and if you request the result in a json-format and try to insert this in a memo, you are not always sure you see the result completely.
A workarround is asking the info in fe php-form and filter the result ...
I note that there is a package foreseen FPexif to treat the exif.
Some questions:
Is it possible to retrieve all info from an exif ?  For as far I saw, Fpexif reads out some info, but not all. 
In the exif we have several section which are filled in by
1) the firm of the camera with his proper tagnames and info
2) Programs that treated the image fe Adobe ...

Part 1 and part 2 are for me very interestfull.  Part 2 is filled in by using fe adobe and there you get a history of what is done, which programm was used, the date it was used ...

Problem is in this case is that info is there, but the tag, fieldname is depended of the softwarehouse or camera-firm.

For as far I saw the package, you can retrieve info on condition you know the fieldname inserted in the class.
class=><fieldname>
The later however you not always know.
 

wp

  • Hero Member
  • *****
  • Posts: 11916
Re: FPexif-package Retrieve all exif-info ?
« Reply #1 on: January 23, 2019, 09:31:54 am »
FPExif iterates through all EXIF records found, but deciphers only those which it knows. Therefore, it may well be that there are some fields which it does not display.

1) the firm of the camera with his proper tagnames and info
Aren't these the Make and Model tags? There may be more specific information in the MakerNotes field, but this information is not documented and difficult to access. Some people reverse-engineered the notes for some camera models, and these results are included, but others are left undecoded.

2) Programs that treated the image fe Adobe ...
There is a standard tag "Software". I saved one of my own photos with Paintshop Pro, and this field was populated now. So, maybe this is what you need.

Try the attached demo.

WimVan

  • Jr. Member
  • **
  • Posts: 85
Re: FPexif-package Retrieve all exif-info ?
« Reply #2 on: January 23, 2019, 10:06:49 am »
Thanks for the answer.
The maker-notes-section is the for me most interesting part.  There the camera-producer enters data (tags and content) taht are typical for his images ...
That's why Exiftools has so much updates (if you use fe geosetter).  A part the camera-tags, Nikon fe also inserts data about the used objective.  Sometimes they even add the serial of the camera and the serial of the used lens.
Sometimes we can retrieve how many click are made by the camera and can even differ between a jpeg and a nef.
I now dreaming ....
A trigger in the package that gets the last exiftool-version (stuff used by geosetter) and filter it so that new tags are added ?
I have for the moment over more than 900 different tag-names grouped by camera, lens. 
This info can also be found on the net.
Just an idea of mine...

wp

  • Hero Member
  • *****
  • Posts: 11916
Re: FPexif-package Retrieve all exif-info ?
« Reply #3 on: January 23, 2019, 10:25:17 am »
Can you post one of the Nikon photos on Dropbox/GoogleDrive etc and share the link? (You can send me a PM with the link if you don't want to publish the photo). fpexif does analyze the Nikon MakerNote tags which maybe can be extended when there is an image for testing.

An important note regarding MakerNote in fpexif: Be careful when you edit EXIF tags. Some MakerNote tags are written with offsets to data fields being relative to the begin of the EXIF structure. When you edit standard EXIF tags the size of their data fields may change, and all offsets to data in the EXIF structure will change. While this can be corrected for the standard tags it is very risky for MakerNote fields which are poorly documented and usually only partly decoded. You must expect loss of the MakerNote tag in the worst case.

WimVan

  • Jr. Member
  • **
  • Posts: 85
Re: FPexif-package Retrieve all exif-info ?
« Reply #4 on: January 23, 2019, 12:05:46 pm »
Give me some days.  I'll ask to my group to deliver pictures from different Nikon (Jpeg and NEF) and Canon (Jpeg and RAW) and Fujifilm (Jpeg and RAF). from the latest camera's
And you are right, changing data in the Makernotes-section is dangerous, but I can not see wy we should modify data in tha section.  It is proper data coming from the camera and the used lenses...
Why should we change the number of clicks we made with the camera?  to cheat ourself  of some one else if we want to sell it?
Changing the creationdate (because our camera can have a not-synchronised date), gps-entry, author-entry.
And there is a small section that we can use without any problem if we respect the foreseen space

I once changed the Camera-name to an older one so I could open the image with Adobe Lightroom, fotoshop.  They uses the name to check it in a list to get availability to Photoshop and/or Lightroom.  After working on it, I rechanged the cameraname.

Any way nice stuff.

wp

  • Hero Member
  • *****
  • Posts: 11916
Re: FPexif-package Retrieve all exif-info ?
« Reply #5 on: January 23, 2019, 03:13:21 pm »
Of course, changing MakerNote data is risky. But it is worse: changing any data is risky if you are interested in MakerNotes.

EXIF consists of several arrays of records with an integer for tag ID, an integer for the tag size (bytes) and an integer for the tag data. The tag data, however, are written within the record only if the byte size is at most 4 - in all other cases the tag's data are written somewhere else, and the data field contains only the offset to the data. This offset refers to the beginning of the EXIF structure.

And this is the problem: Many manufacturers use the same structure within the MakerNote record - i.e. write offsets from the beginning of the EXIF structure, not relative to the beginning of the MakerNotes. This means than, when for example there is a Description record (which is a well-documented standard EXIF tag) before the MakerNotes and you edit the description the MakerNotes will shift by some bytes - but the tags within the MakerNotes still are seen relative to the beginning of the EXIF segment. To fix this a program must decode the entire MakerNotes and after editing it must rewrite all MakerNote tags with their new offsets. If this does not occur decoding of the MakerNotes of an edited file will find the wrong offset and the reader will probably crash. Therefore, many programs remove the MakerNotes from the EXIF segment.

I am sure, however, that Adobe knows all the internals of any MakerNotes. Therefore, I am not surprised that you could read the EXIF data of the modified image. Don't expect this to be true for an arbitrary other program.

Changing the creation date and gps coordinates, I think, is not critical because these data blocks have a fixed size and will not modify any data offsets. The author tag, however, is critical because of its variable length (at least for fpexif).

WimVan

  • Jr. Member
  • **
  • Posts: 85
Re: FPexif-package Retrieve all exif-info ?
« Reply #6 on: January 23, 2019, 05:30:09 pm »
Thanks for the reply.
I normaly get all needed tag-info for Nikon from
https://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Nikon.html

It is the info delivered by Phil Harvey who own exiftool.

adn here you can find all known tags for several camera's firms

https://www.sno.phy.queensu.ca/~phil/exiftool/TagNames

wp

  • Hero Member
  • *****
  • Posts: 11916
Re: FPexif-package Retrieve all exif-info ?
« Reply #7 on: January 23, 2019, 06:24:55 pm »
I know. But even this well-known site is lacking important details which I found e.g. in http://www.exiv2.org/makernote.html

vrull

  • Full Member
  • ***
  • Posts: 118
Re: FPexif-package Retrieve all exif-info ?
« Reply #8 on: November 24, 2019, 07:32:53 am »
My two cents, just for completeness sake.

The package fpexif is not installed in Lazarus by default, so it can be found there:
https://sourceforge.net/p/lazarus-ccr/svn/7194/tree/components/fpexif/

Attached is a modified version of the demo by WP, which displays all tags with their values found in the provided JPEG file.

Birger52

  • Sr. Member
  • ****
  • Posts: 309
Re: FPexif-package Retrieve all exif-info ?
« Reply #9 on: October 04, 2020, 04:51:45 pm »
Just info.
Fiddling a little around with this (pfexif), - well actually just putting it to use - and had to make a change...
Will definitely not presume to be an expert, but i did get some unexpected runtime errors, in file fpeExifData line 1520 (19 as posted here) in a
function TExposureTimeTag.GetAsString: String;
see below
Code: Pascal  [Select][+][-]
  1. function TExposureTimeTag.GetAsString: String;
  2. var
  3.   floatVal: Double;
  4.   fmt1, fmt2: String;
  5.   p: Integer;
  6. begin
  7.   floatVal := GetAsFloat;
  8. {   BS 2020 10 04 line 1516 was
  9.   if IsNaN(floatVal) then
  10.     BS 2020 10 04 }
  11.   if FFormatStr = '' then begin
  12.     if IsNaN(floatVal) or(FloatVal = 0) then
  13.       Result := ''
  14.     else if floatVal >= 10 then
  15.       Result := Format('%.0fs', [floatVal])
  16.     else if floatVal >= 1 then
  17.       Result := Format('%.1fs', [floatVal])
  18.     else
  19.       Result := Format('1/%.0fs', [1.0/floatVal]);
  20.   end else
  21.   begin
  22.     p := pos(';', FFormatStr);
  23.     if p > 0 then begin
  24.       fmt1 := copy(FFormatStr, 1, p-1);
  25.       fmt2 := copy(FFormatStr, p+1, MaxInt);
  26.       if floatVal < 1.0 then
  27.         Result := Format(fmt1, [1.0/floatVal])
  28.       else
  29.         Result := Format(fmt2, [floatVal]);
  30.     end else
  31.       Result := Format(FFormatStr, [floatVal]);
  32.   end;
  33. end;
  34.  

The reason - well, FFormatStr is '' and floatVal is 0, so in the line raising the exception, there is a division by 0.
WHY they are empty and 0, I don't know ;)
This fix (Line 12 was = line 9), doesn't do anything but remove the exception; There are lines in output, with no (string) tag.
The values of these empty tags, do seem to duplicates of other Tags tho...

Lazarus 2.0.8 FPC 3.0.4
Win7 64bit
Playing and learning - strictly for my own pleasure.

wp

  • Hero Member
  • *****
  • Posts: 11916
Re: FPexif-package Retrieve all exif-info ?
« Reply #10 on: October 05, 2020, 10:23:11 am »
I think that the case should be handled outside the empty-string condition because the division by zero and the NaN will affect the other case as well. Please test this code and report back (I cannot test myself because I don't have a test image for this issue):

Code: Pascal  [Select][+][-]
  1. function TExposureTimeTag.GetAsString: String;
  2. var
  3.   floatVal: Double;
  4.   fmt1, fmt2: String;
  5.   p: Integer;
  6. begin
  7.   floatVal := GetAsFloat;
  8.   if IsNaN(floatVal) or (floatVal = 0) then
  9.     Result := ''
  10.   else
  11.   if FFormatStr = '' then begin
  12.     if floatVal >= 10 then
  13.       Result := Format('%.0fs', [floatVal])
  14.     else if floatVal >= 1 then
  15.       Result := Format('%.1fs', [floatVal])
  16.     else
  17.       Result := Format('1/%.0fs', [1.0/floatVal]);
  18.   end else
  19.   begin
  20.     p := pos(';', FFormatStr);
  21.     if p > 0 then begin
  22.       fmt1 := copy(FFormatStr, 1, p-1);
  23.       fmt2 := copy(FFormatStr, p+1, MaxInt);
  24.       if floatVal < 1.0 then
  25.         Result := Format(fmt1, [1.0/floatVal])
  26.       else
  27.         Result := Format(fmt2, [floatVal]);
  28.     end else
  29.       Result := Format(FFormatStr, [floatVal]);
  30.   end;
  31. end;

 

TinyPortal © 2005-2018