ImageMagick 6.5.0 crop behavior

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
mkoppanen
Posts: 309
Joined: 2007-06-09T07:06:32-07:00

ImageMagick 6.5.0 crop behavior

Post 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?
Mikko Koppanen
My blog: http://valokuva.org
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: ImageMagick 6.5.0 crop behavior

Post by magick »

Most likely you are dealing with a virtual canvas. Add MagickResetImagePage() between crops to get the expected results.
mkoppanen
Posts: 309
Joined: 2007-06-09T07:06:32-07:00

Re: ImageMagick 6.5.0 crop behavior

Post by mkoppanen »

Yes, looks like it was an issue with a virtual canvas. Thanks!
Mikko Koppanen
My blog: http://valokuva.org
Post Reply