MagickCropImage

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
168gr
Posts: 47
Joined: 2013-01-09T22:46:19-07:00
Authentication code: 6789

MagickCropImage

Post by 168gr »

Am I misunderstanding this function?

I have an image, 1024 x 576 and I'm trying to crop a 400 x 300 area out of the top left.

Code: Select all

fprintf( stderr, "Before crop, image is %d x %d\n", MagickGetImageWidth( temp_mw ), MagickGetImageHeight( temp_mw ) );
MagickCropImage( temp_mw, 400, 300, 0, 0);
fprintf( stderr, "After crop, image is %d x %d\n", MagickGetImageWidth( temp_mw ), MagickGetImageHeight( temp_mw ) );
I'm not getting what I expect though:

Code: Select all

Before crop, image is 1024 x 576
After crop, image is 400 x 204
I don't understand why the cropped image height is 204 instead of 300.
168gr
Posts: 47
Joined: 2013-01-09T22:46:19-07:00
Authentication code: 6789

Re: MagickCropImage

Post by 168gr »

No ideas, eh? I'll try to extract and post some more details. Something ain't right, surely my code, but I can't for the life of me figure out what it is.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: MagickCropImage

Post by anthony »

That should not happen... UNLESS the input image has a virtual canvas offset!!!!

See...Crop an image with existing page geometry
http://www.imagemagick.org/Usage/crop/#crop_page

I think you have been missing the equivalent of +repage
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply