Page 1 of 1

gflBitmapSetEXIFValueRationalArray2

Posted: Fri Jul 03, 2009 10:38 pm
by madiazg
Hello,
Can you explain me with an example How the function is used to store GPS data?
For example, the latitude 28ยบ 26' 59.55", Can you tell me how to be added to the EXIF information of the picture?

Regards...
Miguel Angel
http://imagen3d.site88.net

Re: gflBitmapSetEXIFValueRationalArray2

Posted: Sat Jul 04, 2009 8:08 am
by dominique
Hi Madiazg,
I test it this morning for you. With C++Builder, you can test this, work for me :

Code: Select all

        // Lib init
        gflLibraryInit();
        // Filenames
        AnsiString lFileName = "_MG_5209.JPG";
        AnsiString lDestFileName = "_MG_5209_TRT.JPG";
        // Load & Save structures
        GFL_FORMAT_INFORMATION  mFormatInfo;
        GFL_FILE_INFORMATION    lInformation;
        GFL_LOAD_PARAMS         mLoadOption;
        GFL_SAVE_PARAMS         mSaveOption;
        GFL_BITMAP*             mOriBitmap;
        GFL_EXIF_DATAEX*        mEXIFData2;
        gflGetDefaultLoadParams( &mLoadOption );
        mLoadOption.Flags |= GFL_LOAD_READ_ALL_COMMENT;
        mLoadOption.Flags |= GFL_LOAD_METADATA;
        mLoadOption.Flags |= GFL_LOAD_COMMENT;
        GFL_ERROR mError = gflLoadBitmap(lFileName.c_str(), &mOriBitmap, &mLoadOption, &lInformation);
        // Getting EXIF data from the source file
        mEXIFData2 = gflBitmapGetEXIF2(mOriBitmap);
        // Adding some GPS Data
        char lLat[2];
        memset(lLat, 2, 0);
        lLat[0] = 'N';
        gflBitmapSetEXIFValueString2(mEXIFData2, GFL_EXIF_GPS_IFD, 0x0001, lLat);
        GFL_UINT32 lpPQ[6];
        lpPQ[0] = 28;   lpPQ[1] = 1;
        lpPQ[2] = 26;   lpPQ[3] = 1;
        lpPQ[4] = 119;   lpPQ[5] = 2;
        gflBitmapSetEXIFValueRationalArray2(mEXIFData2, GFL_EXIF_GPS_IFD, 0x0002, lpPQ, 3);
        // Removing all metadata from the GFL_BITMAP
        // And adding the new EXIF data
        gflBitmapRemoveMetaData(mOriBitmap);
        gflBitmapSetEXIF2(mOriBitmap, mEXIFData2);
        // Save file
        gflGetDefaultSaveParams(&mSaveOption);
        mSaveOption.Flags       = GFL_SAVE_REPLACE_EXTENSION | GFL_SAVE_ICC_PROFILE;
        mSaveOption.FormatIndex = 0;
        mSaveOption.Quality    = 50;
        gflSaveBitmap(lDestFileName.c_str(), mOriBitmap, &mSaveOption);
        // Free ressources
        gflFreeFileInformation(&lInformation);
        gflFreeBitmap(mOriBitmap);
        gflFreeEXIF2(mEXIFData2);
        gflLibraryExit();
You can complete the GPS tag following this link : http://www.sno.phy.queensu.ca/~phil/exi ... s/GPS.html

Re: gflBitmapSetEXIFValueRationalArray2

Posted: Sat Jul 04, 2009 1:38 pm
by madiazg
Thank you very much Dominique.
The code works correctly.
In Delphi:

Code: Select all

var
  pq: array[0..5] of integer;
...
begin
...
    pq[0] := 28;  pq[1] := 1;
    pq[2] := 26;  pq[3] := 1;
    pq[4] := 119; pq[5] := 2;
    gflBitmapSetEXIFValueRationalArray2(EXIF2,GFL_EXIF_GPS_IFD,2,@pq,3);
...
end;
In Libgfl.pas:

Code: Select all

procedure gflBitmapSetEXIFValueRationalArray2(exif: PGFL_EXIF_DATAEX; ifd, tag: GFL_UINT16; const pq: PGFL_UINT32; count: GFL_INT32); stdcall;
...
procedure gflBitmapSetEXIFValueRationalArray2; external GflDLL;
Regards...
Miguel Angel
http://imagen3d.site88.net

Re: gflBitmapSetEXIFValueRationalArray2

Posted: Wed Sep 30, 2009 2:26 pm
by Doga
Hi.

Unlike JPG, for format TIFF this code does not work. After file saving, in it metadata there is only this line: "LIBFORMAT (c) Pierre-e Gougelet".

What to do?

Win XP Pro SP3, CodeGear RAD Studio 2007 (CBuilder), GFL SDK v3.11 (I use libgfl.lib created from libgfl311.dll by implib.exe)

Re: gflBitmapSetEXIFValueRationalArray2

Posted: Wed Sep 30, 2009 2:49 pm
by xnview
Doga wrote: Unlike JPG, for format TIFF this code does not work. After file saving, in it metadata there is only this line: "LIBFORMAT (c) Pierre-e Gougelet".
You can only edit exif on jpeg

Re: gflBitmapSetEXIFValueRationalArray2

Posted: Wed Sep 30, 2009 2:58 pm
by Doga
Badly.When this possibility for format TIFF will be added?