gflBitmapSetEXIFValueRationalArray2

Discussions on GFL SDK, the graphic library for reading and writing graphic files

Moderators: XnTriq, xnview

Post Reply
User avatar
madiazg
Posts: 82
Joined: Wed Jul 18, 2007 8:00 pm
Location: Tenerife - Islas Canarias
Contact:

gflBitmapSetEXIFValueRationalArray2

Post by madiazg » Fri Jul 03, 2009 10:38 pm

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

User avatar
dominique
Posts: 72
Joined: Thu Nov 08, 2007 9:22 am

Re: gflBitmapSetEXIFValueRationalArray2

Post by dominique » Sat Jul 04, 2009 8:08 am

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
Dom

User avatar
madiazg
Posts: 82
Joined: Wed Jul 18, 2007 8:00 pm
Location: Tenerife - Islas Canarias
Contact:

Re: gflBitmapSetEXIFValueRationalArray2

Post by madiazg » Sat Jul 04, 2009 1:38 pm

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

Doga
Posts: 2
Joined: Wed Sep 30, 2009 2:03 pm

Re: gflBitmapSetEXIFValueRationalArray2

Post by Doga » Wed Sep 30, 2009 2:26 pm

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)

User avatar
xnview
Author of XnView
Posts: 31607
Joined: Mon Oct 13, 2003 7:31 am
Location: France
Contact:

Re: gflBitmapSetEXIFValueRationalArray2

Post by xnview » Wed Sep 30, 2009 2:49 pm

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
Pierre.

Doga
Posts: 2
Joined: Wed Sep 30, 2009 2:03 pm

Re: gflBitmapSetEXIFValueRationalArray2

Post by Doga » Wed Sep 30, 2009 2:58 pm

Badly.When this possibility for format TIFF will be added?

Post Reply