MagickGetImageSize

The MagickWand interface is a new high-level C API interface to ImageMagick core methods. We discourage the use of the core methods and encourage the use of this API instead. Post MagickWand questions, bug reports, and suggestions to this forum.
Post Reply
*void

MagickGetImageSize

Post 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.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Post 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.
Post Reply