Problem in Cropping the image
-
- Posts: 69
- Joined: 2013-05-22T09:42:33-07:00
- Authentication code: 6789
Problem in Cropping the image
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
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
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Problem in Cropping the image
You are missing the keyword "-crop".
snibgo's IM pages: im.snibgo.com
-
- Posts: 69
- Joined: 2013-05-22T09:42:33-07:00
- Authentication code: 6789
Re: Problem in Cropping the image
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.
convert plant.jpg -crop 2325x3750+2358+3820 +repage plant1.jpg
still getting the same image.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Problem in Cropping the image
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.
-
- Posts: 69
- Joined: 2013-05-22T09:42:33-07:00
- Authentication code: 6789
Re: Problem in Cropping the image
I am using ImageMagick 6.7.7-10.
Input Image:
http://f.cl.ly/items/1s0z3j3z3c2o3a23031G/plant.jpg
Output Image:
http://f.cl.ly/items/21073D1l3d1128253s0N/plant1.jpg
Input Image:
http://f.cl.ly/items/1s0z3j3z3c2o3a23031G/plant.jpg
Output Image:
http://f.cl.ly/items/21073D1l3d1128253s0N/plant1.jpg
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Problem in Cropping the image
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?
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?
snibgo's IM pages: im.snibgo.com
-
- Posts: 69
- Joined: 2013-05-22T09:42:33-07:00
- Authentication code: 6789
Re: Problem in Cropping the image
W: 2325
H: 3750
X: 2358
Y: 3820
H: 3750
X: 2358
Y: 3820
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Problem in Cropping the image
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.
snibgo's IM pages: im.snibgo.com
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Problem in Cropping the image
Yes. I pointed that out above. I think the OP does not understand IM syntax for cropping.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.
"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
How did you determine these coordinates? What tool did you use to measure them? Was that measured in pixels?W: 2325
H: 3750
X: 2358
Y: 3820
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Problem in Cropping the image
Perhaps this will help the OP:
Code: Select all
+------------------------------------+
| ^ |
| | |
| Y |
| | |
| V |
| +------------+ ^ |
|<--X-->| | | |
| | | | |
| | | H |
| | | | |
| | | | |
| | | | |
| +------------+ V |
| |
| <-----W------> |
| |
+------------------------------------+
snibgo's IM pages: im.snibgo.com
-
- Posts: 69
- Joined: 2013-05-22T09:42:33-07:00
- Authentication code: 6789
Re: Problem in Cropping the image
I used photoshop to get those dimensions.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Problem in Cropping the image
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
-
- Posts: 69
- Joined: 2013-05-22T09:42:33-07:00
- Authentication code: 6789
Re: Problem in Cropping the image
Got the solution for this. Its fixed thanks a lot.