I'm successfully reading common tiff ascii tags (keys, Software, DocumentName, HostComputer, DateTime, ...) in Delphi using,
pTag : PFITAG;
Result := FreeImage_GetMetadata(FIMD_EXIF_MAIN, FreeBitmap.Dib, PAnsiChar(Key), pTag);
if Result then
Value := PAnsiChar(FreeImage_TagToString(FIMD_EXIF_MAIN, pTag));
That works perfectly.
But I'm having problems saving the tags back. The API seems quite straight forward, and the following code executes properly (all calls return success).
pTag := FreeImage_CreateTag;
if pTag <> nil then
FreeImage_SetTagKey( pTag, PAnsiChar(Key) );
FreeImage_SetTagLength(pTag, Length(Value) + 1);
FreeImage_SetTagCount(pTag, Length(Value) + 1);
FreeImage_SetMetadata(FIMD_EXIF_MAIN, FreeBitmap.Dib, FreeImage_GetTagKey(pTag), pTag);
FreeImage_DeleteTag( pTag );
I even validate that the tag is properly set by calling FreeImage_GetMetadata and it properly returns the tag value set.
But then when the call to
FreeImage_Save is made,
the metadata tags are simply not saved. I checked with my code and with the AsTiffTagViewer utility.
Is there anything I'm missing to save the "standard" tiff meta data tags?
Thanks a lot,
Can you give some examples of tags that cannot be saved (i.e. tag keys) ?
First, thanks for your help. Much appreciated.
That tags I'm trying to save are all defined in the
exif_exif_tag_table found in taglib.cpp.
For example, the keys, 'Software', 'Model', 'Make', 'DateTime', ...
I did more tests and used the DLL from the Win32 download package,
I was previously using a DLL I think from version 188.8.131.52 as that is the only 64 bit prebuilt DLL I could find.
Now the problem is different. The tags seemed saved properly. I can see them properly with the AsTiffTagViewer utility.
But I must be doing something wrong because only the DateTime tag can be read completely. All the other tags in my test case,
Check( Dest.DocumentNameTag = 'DocumentNameTag' );
Check( Dest.ImageDescriptionTag = 'ImageDescriptionTag' );
Check( Dest.ScannerMakeTag = 'ScannerMakeTag' );
Check( Dest.ScannerModelTag = 'ScannerModelTag' );
Check( Dest.PageNameTag = 'PageNameTag' );
Check( Dest.SoftwareTag = 'SoftwareTag' );
Check( Dest.DateTimeTag = 'DateTimeTag' );
Check( Dest.ArtistTag = 'ArtistTag' );
Check( Dest.HostComputerTag = 'HostComputerTag' );
only return the first letter. For example, the DocumentNameTag returns 'D' when loaded. But the same code is used for the DataTimeTag, and that one returns the full string.
My code to load the tag is quite simple as seen in the first post.
At this point, I'm not sure if,
I am saving the tag properly because I can properly read tags from other tiff files created by other software.
Or, I'm not reading the tags properly, because the AsTiffTagViewer properly displays that tags I have saved.
Log in to post a comment.