Page 1 of 1

Ping for very large BMP image don't work

Posted: 2014-03-21T00:51:34-07:00
by wizard29
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?

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

Posted: 2014-03-21T16:52:42-07:00
by magick
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.

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

Posted: 2014-03-24T00:53:56-07:00
by wizard29
Thank you very much!