Page 1 of 1

ImageMagick 6.5.0 crop behavior

Posted: 2009-04-01T11:55:16-07:00
by mkoppanen
Hello,

I am staring at the following code but can't really see how I end up the geometry at the end:

Code: Select all

#include <stdio.h>
#include <stdlib.h>
#include <wand/MagickWand.h>

int main() {
        MagickWand *m_wand;
        PixelWand *pixel;

        MagickWandGenesis();

        m_wand = NewMagickWand();
        pixel = NewPixelWand();

        MagickNewImage(m_wand, 200, 150, pixel);

        MagickThumbnailImage(m_wand, 120, 120);

        printf("Geometry before first crop: %dx%d\n", MagickGetImageWidth(m_wand), MagickGetImageHeight(m_wand));

        MagickCropImage(m_wand, 100, 100, 10, 10);

        printf("Geometry before second crop: %dx%d\n", MagickGetImageWidth(m_wand), MagickGetImageHeight(m_wand));

        MagickCropImage(m_wand, 100, 40, 0, 30);

        printf("Geometry after second crop: %dx%d\n", MagickGetImageWidth(m_wand), MagickGetImageHeight(m_wand));

        m_wand = DestroyMagickWand(m_wand);
        pixel = DestroyPixelWand(pixel);

        MagickWandTerminus();
        return 0;
}
Outputs:

Geometry before first crop: 120x120
Geometry before second crop: 100x100
Geometry after second crop: 90x40

Where does the 90x40 come from?

Re: ImageMagick 6.5.0 crop behavior

Posted: 2009-04-01T12:21:02-07:00
by magick
Most likely you are dealing with a virtual canvas. Add MagickResetImagePage() between crops to get the expected results.

Re: ImageMagick 6.5.0 crop behavior

Posted: 2009-04-04T18:06:51-07:00
by mkoppanen
Yes, looks like it was an issue with a virtual canvas. Thanks!