Page 1 of 1

Problem in Cropping the image

Posted: 2013-06-14T15:45:52-07:00
by helloworld
I am trying to convert an image to the below dimensions with below command and the cropped image i get is not the expected image.

Command

convert plant.jpg 2325x3750+2358+3820 plant1.jpg

W: 2325
H: 3750
X: 2358
Y: 3820

Error

Its not giving me what i expected.

Original Image:
http://f.cl.ly/items/1s0z3j3z3c2o3a23031G/plant.jpg

Cropped Image:
http://f.cl.ly/items/21073D1l3d1128253s0N/plant1.jpg

So basically i cropped only the plant

Re: Problem in Cropping the image

Posted: 2013-06-14T15:52:35-07:00
by snibgo
You are missing the keyword "-crop".

Re: Problem in Cropping the image

Posted: 2013-06-14T15:57:26-07:00
by helloworld
Sorry i forgot to add -crop in the image. But i typing the correct command.

convert plant.jpg -crop 2325x3750+2358+3820 +repage plant1.jpg

still getting the same image.

Re: Problem in Cropping the image

Posted: 2013-06-14T16:01:00-07:00
by fmw42
helloworld wrote:Sorry i forgot to add -crop in the image. But i typing the correct command.

convert plant.jpg -crop 2325x3750+2358+3820 +repage plant1.jpg

still getting the same image.

What version of IM and platform? Can you provide a link to your input and output images?

The problem is you are supplying an offset outside the image. The +X+Y are not the bottom right corner coordinatess but the offset for the top left. The WxH is the desired size of the cropped region starting at +X+Y.

Re: Problem in Cropping the image

Posted: 2013-06-14T16:07:14-07:00
by helloworld

Re: Problem in Cropping the image

Posted: 2013-06-14T16:12:19-07:00
by snibgo
As Fred says.

1. What width should the output be?

2. What height should the output be?

3. What x-coordinate in the original should the output start at?

4. What y-coordinate in the original should the output start at?

Re: Problem in Cropping the image

Posted: 2013-06-14T16:15:50-07:00
by helloworld
W: 2325
H: 3750
X: 2358
Y: 3820

Re: Problem in Cropping the image

Posted: 2013-06-14T16:28:54-07:00
by snibgo
But your original is only 3000 pixels wide. If the output starts at x-coord 2358, and is 2325 pixels wide, 2358+2325 = 4683. 4683 > 3000.

Re: Problem in Cropping the image

Posted: 2013-06-14T16:41:00-07:00
by fmw42
snibgo wrote:But your original is only 3000 pixels wide. If the output starts at x-coord 2358, and is 2325 pixels wide, 2358+2325 = 4683. 4683 > 3000.
Yes. I pointed that out above. I think the OP does not understand IM syntax for cropping.

"The problem is you are supplying an offset outside the image. The +X+Y are not the bottom right corner coordinates but the offset for the top left. So, WxH is the desired size (dimensions in pixels) of the cropped region starting at pixel +X+Y relative to the top left corner of the input image."


see
http://www.imagemagick.org/script/comma ... s.php#crop
http://www.imagemagick.org/script/comma ... p#geometry
http://www.imagemagick.org/Usage/crop/#crop

W: 2325
H: 3750
X: 2358
Y: 3820
How did you determine these coordinates? What tool did you use to measure them? Was that measured in pixels?

Re: Problem in Cropping the image

Posted: 2013-06-14T17:27:41-07:00
by snibgo
Perhaps this will help the OP:

Code: Select all

+------------------------------------+
|           ^                        |
|           |                        |
|           Y                        |
|           |                        |
|           V                        |
|       +------------+ ^             |
|<--X-->|            | |             |
|       |            | |             |
|       |            | H             |
|       |            | |             |
|       |            | |             |
|       |            | |             |
|       +------------+ V             |
|                                    |
|       <-----W------>               |
|                                    |
+------------------------------------+

Re: Problem in Cropping the image

Posted: 2013-06-17T11:53:14-07:00
by helloworld
I used photoshop to get those dimensions.

Re: Problem in Cropping the image

Posted: 2013-06-17T12:08:45-07:00
by fmw42
helloworld wrote:I used photoshop to get those dimensions.

Were they in pixels or some other units? Were you getting the coordinates from the cursor or from the rulers. Were they the top left and bottom right corners? Or were they the width, height and top left x,y coordinates.

Something is obviously wrong if you are measuring pixels that are outside the bounds of your image.

What features are you trying to crop? Can you draw a box in PS on your image to show the area you want? I can open that in PS and see what the correct coordinates should be for IM.

If you open the image in PS and open the Info window, then select the crop tool and draw a box, the Info panel should show you the Width and Height and top left X,Y coordinates in pixels. Before you do that open the Preferences panel and select Units and Rulers and set the Units to pixels

Re: Problem in Cropping the image

Posted: 2013-06-21T14:21:23-07:00
by helloworld
Got the solution for this. Its fixed thanks a lot.