Page 1 of 1
[Resolved] Negative Offsets in geometry when cropping
Posted: 2008-11-17T05:21:21-07:00
by weakish
I have some difficulties in understanding the usage of negative offsets in geometry.
Code: Select all
convert -crop 50%x100%+0+0 in.jpg out.jpg
convert -crop 50%x100%-0-0 in.jpg out.jpg
give the same result. (Got the left half of the picture.)
Can anyone give some hints? Thanks in advance.
Re: Negative Offsets in geometry when cropping
Posted: 2008-11-17T13:04:56-07:00
by fmw42
weakish wrote:I have some difficulties in understanding the usage of negative offsets in geometry.
Code: Select all
convert -crop 50%x100%+0+0 in.jpg out.jpg
convert -crop 50%x100%-0-0 in.jpg out.jpg
give the same result. (Got the left half of the picture.)
Can anyone give some hints? Thanks in advance.
+0+0 and -0-0 both refer to the upper left corner pixel. so you won't see any differences. If you put +20+20, you will have an image that has its upper left corner starting 20 pixels in from your original. Negative offsets will likely crop 20 pixels from the lower right corner and may disregard your size specification, I am not sure. If you want to crop from one side or corner add -geometry and use positive offsets.
see
http://www.imagemagick.org/script/comma ... s.php#crop
Also your syntax should possibly be
convert in.jpg -crop ... out.jpg
See
http://www.imagemagick.org/Usage/basics/#cmdline Although in this case in likely does not matter as your will be cropping as you read the input in your syntax rather than loading the image and then cropping it in the latter syntax (assuming you can use -crop while reading the input).
Also note that after cropping, you want to remove the virtual page information using +repage
convert in.jpg -crop ... +repage out.jpg
see
http://www.imagemagick.org/Usage/crop/#crop
Re: Negative Offsets in geometry when cropping
Posted: 2008-11-18T01:09:56-07:00
by anthony
The offset only specifys the position of the rectangle you give
so 100x100-20-20 will specify a rectangle that is 20 pixel to the left and above the top of the image. Rather useless unless your image is a layer image with a negative offset (most images are not).
If you do not specify the size of the crop rectangle it is the size of the virtual canvas, which in most image is actual image size (but not always).
If you don't specify a offset, you get a tiled crop.
Each of these types are exampled in IM examples, Cutting and Borders.
Re: Negative Offsets in geometry when cropping
Posted: 2008-11-18T06:00:48-07:00
by weakish
Thanks to your replies. Now I have a better understanding on this expression of geometry in IM.
I had confused it with the geometry concept in X window, where -0-0 refers to the right down corner.
Re: [Resolved] Negative Offsets in geometry when cropping
Posted: 2008-11-18T17:02:15-07:00
by anthony
I figured.