Ping for very large BMP image don't work

Magick++ is an object-oriented C++ interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning Magick++.
Post Reply
wizard29
Posts: 58
Joined: 2014-03-21T00:40:16-07:00
Authentication code: 6789
Location: Russia, Saint Petersburg
Contact:

Ping for very large BMP image don't work

Post by wizard29 » 2014-03-21T00:51:34-07:00

Hello.
I try to read very large BMP image from a file. The dimension of the image is 25000x19000 pixel.
following code generates the Magick::ErrorResourceLimit exception:

Code: Select all

    Magick::Image img;
    try
    {
        img.ping("StartupImage.bmp");
    }
    catch (const Magick::Exception &error_)
    {
        std::cout<<error_.what();
    }
In other cases when i try to ping PNG image with the same size for example ping function works fine.

How to solve this problem?

User avatar
magick
Site Admin
Posts: 11014
Joined: 2003-05-31T11:32:55-07:00

Re: Ping for very large BMP image don't work

Post by magick » 2014-03-21T16:52:42-07:00

Add '[0]' to your filename. That reads the first image metadata and immediately returns. Without the '[0]', the image pixels are scanned but no pixel cache is allocated or traversed. Traversing a large image can be time consuming, so avoiding this step is where Ping gets its performance boost. For most image formats, a single scanline buffer is allocated to assist decoding. The BMP image pixels are stored upside down and sometimes compressed. To facilitate inverting the image and possibly decompressing, we allocate memory for the entire image instead of just a scanline. If the memory request exceeds available resources, the memory is instead allocated on disk and then memory-mapped (assuming ImageMagick resource limits are not exceeded). We could probably put in some 'if' blocks such that when the BMP image is pinged, memory allocation is skipped. We'll need to review the code to see if that is a reasonable compromise.

wizard29
Posts: 58
Joined: 2014-03-21T00:40:16-07:00
Authentication code: 6789
Location: Russia, Saint Petersburg
Contact:

Re: Ping for very large BMP image don't work

Post by wizard29 » 2014-03-24T00:53:56-07:00

Thank you very much!

Post Reply