Page 1 of 1

MagickGetImageSize

Posted: 2006-12-26T16:23:34-07:00
by *void
MagickGetImageSize returns a value of MagickSizeType. My main usage of this will be in conjunction with MagickPingImage to test whether an image is of manageable size beofre actually reading it.

I am calling the MagickWand DLL from another language. I prototyped MagickGetImageSize in the calling program to receive a LONG result. That seems to work, in that I get back the correct size of the (relatively small) images I have.

However, the headers lead me to believe MagickSizeType is a 64-bit type, and that my program is seeing only the low 32 bits of that. If my program comes upon an image file with a 6GB image, I presume my program will receive the size modulo 2**32, and believe it is safe in loading it.

The language I am using has no concept of anything larger than 32 bits, so cannot handle anything larger than that in the calling interface.

It would be nice if there was a MagickWand call that returned a 64-bit image size in the form of a pointer to an array of LONG. My program could then at least test for images larger than 2**32 bytes.

Posted: 2006-12-26T16:36:51-07:00
by magick
MagickSizeType is 64-bits in most cases. Most modern languages support 64-bit in some manner. Visual C++, for example, has a __int64 type. If your wrapper language has no 64-bit support you will need to write a small wrapper around MagickGetImageSize() yourself or compile ImageMagick/MagickWand as true-32-bit. In magick/magick-type.h change 'unsigned long long' to 'unsigned long' or __in64 to int.