#include "Fivewin.ch"
STATIC hLibFI
FUNCTION MAIN()
? GETTAGVALUE( "PROVA.JPG", "Make" )
? GETTAGVALUE( "PROVA.JPG", "DateTime" )
? GETTAGVALUE( "PROVA.JPG", "XResolution" )
? GETTAGVALUE( "PROVA.JPG", "YResolution" )
? GETTAGVALUE( "PROVA.JPG", "NonExistent" )
? SETCOMMENTS( "PROVA.JPG", "Questa è una prova di commento" )
? GETCOMMENTS( "PROVA.JPG" )
RETURN NIL
#define FIMD_COMMENTS 0
#define FIMD_EXIF_MAIN 1
#define FIMD_IPTC 6
#define FIMD_XMP 7
#define FIDT_ASCII 2
FUNCTION GETCOMMENTS( cFile )
RETURN GETTAGVALUE( cFile, "Comment", FIMD_COMMENTS )
FUNCTION SETCOMMENTS( cFile, cComment )
RETURN SETTAGVALUE( cFile, "Comment", cComment, FIMD_COMMENTS )
FUNCTION GETIPTCVALUE( cFile, cKey )
RETURN GETTAGVALUE( cFile, cKey, FIMD_IPTC )
FUNCTION GETTAGVALUE( cFile, cKey, cModel )
LOCAL nFormat, hDib, nTagPtr, nType, xValue
DEFAULT cModel := FIMD_EXIF_MAIN
hLibFI = LOADLIBRARY( "freeimage.dll" )
nFormat = FIGETFILETYPE( cFile, 0 )
hDib = FILOAD( nFormat, cFile, 0 )
FIGETMETADATA( cModel, hDib, cKey, @nTagPtr )
IF nTagPtr != 0
nType = FIGETTAGTYPE( nTagPtr )
xValue = FIGETTAGVALUE( nTagPtr )
IF nType != 2
xValue = BIN2L( xValue )
ENDIF
ENDIF
FIUNLOAD( hDib )
FREELIBRARY( hLibFI )
RETURN xValue
FUNCTION SETTAGVALUE( cFile, cKey, cValue, cModel )
LOCAL nFormat, hDib, nTagPtr
LOCAL lOk := .F.
DEFAULT cModel := FIMD_EXIF_MAIN
hLibFI = LOADLIBRARY( "freeimage.dll" )
nFormat = FIGETFILETYPE( cFile, 0 )
hDib = FILOAD( nFormat, cFile, 0 )
BEGIN SEQUENCE
nTagPtr = FICREATETAG()
IF nTagPtr = 0; BREAK; ENDIF
lOk = FISETTAGKEY( nTagPtr, cKey )
IF !lOk; BREAK; ENDIF
lOk = FISETTAGLENGTH( nTagPtr, LEN( cValue ) )
IF !lOk; BREAK; ENDIF
lOk = FISETTAGCOUNT( nTagPtr, LEN( cValue ) )
IF !lOk; BREAK; ENDIF
lOk = FISETTAGTYPE( nTagPtr, FIDT_ASCII )
IF !lOk; BREAK; ENDIF
lOk = FISETTAGVALUE( nTagPtr, cValue )
IF !lOk; BREAK; ENDIF
lOk = FISETMETADATA( cModel, hDib, cKey, nTagPtr )
IF !lOk; BREAK; ENDIF
lOk = FISAVE( nFormat, hDib, "PROVANUOVO.JPG", 100 )
END SEQUENCE
FIDELETETAG( nTagPtr )
FIUNLOAD( hDib )
FREELIBRARY( hLibFI )
RETURN lOk
DLL STATIC FUNCTION FIGETFILETYPE( cFileName AS LPSTR, nSize AS LONG ) AS LONG;
PASCAL FROM "_FreeImage_GetFileType@8" LIB hLibFI
DLL STATIC FUNCTION FILOAD( nFormat AS LONG, cFileName AS LPSTR, nFlags AS LONG ) AS LONG;
PASCAL FROM "_FreeImage_Load@12" LIB hLibFI
DLL STATIC FUNCTION FISAVE( nFormat AS LONG, hDib AS LONG, cFileName AS LPSTR, nFlags AS LONG ) AS BOOL;
PASCAL FROM "_FreeImage_Save@16" LIB hLibFI
DLL STATIC FUNCTION FIGETMETADATA( nModel AS LONG, hDib AS LONG, cKey AS LPSTR, @nTag AS PTR ) AS BOOL;
PASCAL FROM "_FreeImage_GetMetadata@16" LIB hLibFI
DLL STATIC FUNCTION FIGETTAGTYPE( nTag AS LONG ) AS LONG;
PASCAL FROM "_FreeImage_GetTagType@4" LIB hLibFI
DLL STATIC FUNCTION FIGETTAGVALUE( nTag AS LONG ) AS LPSTR;
PASCAL FROM "_FreeImage_GetTagValue@4" LIB hLibFI
DLL STATIC FUNCTION FIGETTAGKEY( nTag AS LONG ) AS LPSTR;
PASCAL FROM "_FreeImage_GetTagKey@4" LIB hLibFI
DLL STATIC FUNCTION FICREATETAG() AS LONG;
PASCAL FROM "_FreeImage_CreateTag@0" LIB hLibFI
DLL STATIC FUNCTION FIDELETETAG( nTag AS LONG ) AS VOID;
PASCAL FROM "_FreeImage_DeleteTag@4" LIB hLibFI
DLL STATIC FUNCTION FISETTAGKEY( nTag AS LONG, cKey AS LPSTR ) AS BOOL;
PASCAL FROM "_FreeImage_SetTagKey@8" LIB hLibFI
DLL STATIC FUNCTION FISETTAGLENGTH( nTag AS LONG, nLength AS DWORD ) AS BOOL;
PASCAL FROM "_FreeImage_SetTagLength@8" LIB hLibFI
DLL STATIC FUNCTION FISETTAGCOUNT( nTag AS LONG, nCount AS DWORD ) AS BOOL;
PASCAL FROM "_FreeImage_SetTagCount@8" LIB hLibFI
DLL STATIC FUNCTION FISETTAGTYPE( nTag AS LONG, nType AS LONG ) AS BOOL;
PASCAL FROM "_FreeImage_SetTagType@8" LIB hLibFI
DLL STATIC FUNCTION FISETTAGVALUE( nTag AS LONG, cValue AS LPSTR ) AS BOOL;
PASCAL FROM "_FreeImage_SetTagValue@8" LIB hLibFI
DLL STATIC FUNCTION FISETMETADATA( nModel AS LONG, hDib AS LONG, cKey AS LPSTR, nTag AS LONG ) AS BOOL;
PASCAL FROM "_FreeImage_SetMetadata@16" LIB hLibFI
DLL STATIC FUNCTION FIUNLOAD( hDib AS LONG ) AS VOID;
PASCAL FROM "_FreeImage_Unload@4" LIB hLibFI