Problem saving tiff ascii tags

Help
Mike
2013-07-12
2013-07-15
  • Mike

    Mike - 2013-07-12

    Hi,

    I'm successfully reading common tiff ascii tags (keys, Software, DocumentName, HostComputer, DateTime, ...) in Delphi using,

    var
        pTag  : PFITAG;
    begin
        Result := FreeImage_GetMetadata(FIMD_EXIF_MAIN, FreeBitmap.Dib, PAnsiChar(Key), pTag);
        if Result then
        begin
           Value := PAnsiChar(FreeImage_TagToString(FIMD_EXIF_MAIN, pTag));
        end;
    end;
    

    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;
    try
        if pTag <> nil then
        begin
            FreeImage_SetTagKey( pTag, PAnsiChar(Key) );
            FreeImage_SetTagLength(pTag, Length(Value) + 1);
            FreeImage_SetTagCount(pTag, Length(Value) + 1);
            FreeImage_SetTagType(pTag, FIDT_ASCII);
            FreeImage_SetTagValue(pTag, PAnsiChar(Value));
            FreeImage_SetMetadata(FIMD_EXIF_MAIN, FreeBitmap.Dib, FreeImage_GetTagKey(pTag), pTag);
        end;
    finally
        FreeImage_DeleteTag( pTag );
    end;
    

    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,

    Michel

     
  • Hervé Drolon

    Hervé Drolon - 2013-07-12

    Hi,

    Can you give some examples of tags that cannot be saved (i.e. tag keys) ?

    Hervé

     
  • Mike

    Mike - 2013-07-15

    Hi Hervé,

    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,

    http://freeimage.sourceforge.net/download.html

    I was previously using a DLL I think from version 3.15.1.0 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,

    1. I am saving the tag properly because I can properly read tags from other tiff files created by other software.

    2. Or, I'm not reading the tags properly, because the AsTiffTagViewer properly displays that tags I have saved.

    Thanks,

    Michel

     

Log in to post a comment.