Crop Question

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
buntone
Posts: 8
Joined: 2011-07-29T08:23:41-07:00
Authentication code: 8675308

Crop Question

Post by buntone »

How would I crop an image if it is bigger the the supplied dimensions and only crop the dimension that is bigger? Here is the command I have right now:

Code: Select all

convert input.tiff -crop 2269x1950+430+0 +repage -endian lsb -colorspace CMYK -compress LZW output.tff
Any help would be appreciated.
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Crop Question

Post by Bonzo »

You have confused me buntone; may need some examples of input sizes and output sizes :?

What about:

Code: Select all

convert input.tiff -gravity center -crop 2269x1950+0+0 +repage -endian lsb -colorspace CMYK -compress LZW output.tff
This will crop around the center or you might be able to use http://www.imagemagick.org/script/comma ... .php#shave
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Crop Question

Post by fmw42 »

crop should crop to those dimension specified or the size of the image if smaller. So you should get the proper behaviour you seem to want. If I misunderstand, please clarify further or provide a case where it fails.

For example for this example:

convert rose: -crop 200x200+0+0 +repage rose_cropped.png

the result is still the same size as the original rose: image.
buntone
Posts: 8
Joined: 2011-07-29T08:23:41-07:00
Authentication code: 8675308

Re: Crop Question

Post by buntone »

The offset I need messes up everything because it then crops with that offset in mind. Using gravity causes the me to get the wrong part of the image. I want it to only crop if the image dimensions are only bigger than the crop area and ignore the offset otherwise. Is there a way to do this?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Crop Question

Post by fmw42 »

Sorry I am still confused. Can you show us an example of what is happening along with your command. You can upload images to some free server and provide a link here to your images.
Post Reply