Pardon if "32-bit" is archeology in 2020, it's just that I have some time to debug/develop at that machine -- but can pursue other projects, while postponing this one till later. I.e., question is not urgent/critical, simply puzzling.
Using FreeImage DLL, this C test runs perfectly well:
#include <stdio.h>
#include <stdlib.h>
#include <FreeImage.h>
int main( int argc, char **argv ) {
printf("%s\n", FreeImage_GetVersion());
FIBITMAP *im = FreeImage_Load(FreeImage_GetFileType(argv[1], 0), a
+rgv[1], 0);
printf("%d\n", im);
FITAG *tag = FreeImage_CreateTag();
FreeImage_SetTagKey(tag, "Urgency");
FreeImage_SetTagLength(tag, 2);
FreeImage_SetTagCount(tag, 2);
FreeImage_SetTagType(tag, FIDT_ASCII);
FreeImage_SetTagValue(tag, "5");
printf("*\n");
FreeImage_SetMetadata(FIMD_IPTC, im, FreeImage_GetTagKey(tag), tag
+);
printf("*\n");
FreeImage_DeleteTag(tag);
FreeImage_Unload(im);
}
>convert wizard: wiz.jpg
>convert wizard: wiz.tif
>gcc -s -O2 -DWIN32 -fwrapv -fno-strict-aliasing -mms-bitfields -o fit
+est.exe fitest.c -lfreeimage
>fitest.exe wiz.jpg
3.18.0
2729184
*
*
>fitest.exe wiz.tif
3.18.0
2728264
*
*
However, this Perl script fails:
use strict;
use warnings;
use FindBin;
load( $ARGV[0] );
use Inline C => config => inc => "-I$FindBin::Bin",
libs => "-L$FindBin::Bin -lfreeimage";
use Inline C => <<'END_OF_C';
#include <FreeImage.h>
void load(char *fname) {
// FreeImage_Initialise(FALSE);
printf("%s\n", FreeImage_GetVersion());
FIBITMAP *im = FreeImage_Load(FreeImage_GetFileType(fname, 0), fna
+me, 0);
printf("%d\n", im);
FITAG *tag = FreeImage_CreateTag();
FreeImage_SetTagKey(tag, "Urgency");
FreeImage_SetTagLength(tag, 2);
FreeImage_SetTagCount(tag, 2);
FreeImage_SetTagType(tag, FIDT_ASCII);
FreeImage_SetTagValue(tag, "5");
printf("*\n");
FreeImage_SetMetadata(FIMD_IPTC, im, FreeImage_GetTagKey(tag), tag
+);
printf("*\n");
FreeImage_DeleteTag(tag);
FreeImage_Unload(im);
// FreeImage_DeInitialise();
}
END_OF_C
__END__
>perl fitest.pl wiz.jpg
3.18.0
2733096
*
>perl fitest.pl wiz.tif
3.18.0
Perl crashes, hence truncated output -- with call to "FreeImage_SetMetadata" for jpg image, and "FreeImage_Load" for tif image. "FreeImage_Initialise" makes no difference (manual says, it's not required to be called), and same compiler options, which Inline uses, work perfect for pure C, above. There is no such issue for 64 bit environment (of course, a dll of appropriate architecture was used in both cases). Why is this happening and can it be (easily) fixed?