unable to crop image

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
jedierikb
Posts: 20
Joined: 2012-12-13T13:59:27-07:00
Authentication code: 6789

unable to crop image

Post by jedierikb »

I have two 1095x645 png images which load fine in any web browser.

When I run this command on the first image, it crops the image.

Code: Select all

convert img1.png -crop 20.7058823529%x20.8%+59.3129411765+350.88 img1-crop.png
But when I run the same command on the second image, I get an error.

Code: Select all

convert img2.png -crop 20.7058823529%x20.8%+59.3129411765+350.88 img2-crop.png

Code: Select all

convert: geometry does not contain image `ok.png' @ warning/transform.c/CropImage/666.
Searched the forums, and there are suggestions to rebase before cropping, but not sure how that advice applies here.

On Mac running OS10.9.1
Version: ImageMagick 6.8.7-7 Q16 x86_64 2013-11-27 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2014 ImageMagick Studio LLC
Features: DPC Modules
Delegates: bzlib freetype jng jpeg ltdl png xml zlib
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: unable to crop image

Post by snibgo »

You might need to "+repage" before crop. Diagnosis is difficult without the file. You can put it in dropbox.com or similar and paste the URL here.
snibgo's IM pages: im.snibgo.com
jedierikb
Posts: 20
Joined: 2012-12-13T13:59:27-07:00
Authentication code: 6789

Re: unable to crop image

Post by jedierikb »

That was it, thank you. I am guessing that the image file does not have trustworthy sizing information without the repage command?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: unable to crop image

Post by snibgo »

Png files can contain metadata saying the image is at a given offset on a larger canvas. If your crop is within the canvas but not the image, IM warns you. "+repage" removes that metadata.
snibgo's IM pages: im.snibgo.com
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

Re: unable to crop image

Post by glennrp »

jedierikb wrote:That was it, thank you. I am guessing that the image file does not have trustworthy sizing information without the repage command?
It may contain offset information that puts the image outside of the crop area. Compare the output of "identify img1.png" with "identify img2.png". Then
do "convert img2.png +repage img3.png" and look at "identify img3.png".
Post Reply