Page 1 of 1
STRANGE ISSUE WITH CROP COORDINATES
Posted: 2011-02-26T15:33:00-07:00
by goyop
I have been using the crop function to extract sections for MJPEG video clips. It has worked very well for a couple of years and occasionally we change the crop box due to different needs. Up to now it is very simple. I just take one of the JPGs, bring it into PS and lay a pixel grid on top. Then starting in the upper left corner at 0,0 I call out the Y starting point and Y dimension, followed by the X.
Over the last couple days in trying to make some simple crop changes I am running into a strange problem with the new coordinates causing unexpected and hard to figure results. I tried these changes on two machines with different versions of IM.
A head scratcher for me. I am fully prepared to be embarrassed by a simple explanation but I am not seeing it.
Thanks,
Greg
*** FIGURED IT OUT ALTHOUGH STILL UNCERTAIN ABOUT NEGATIVE COORDINATES BUT WE ARE NOT USING THEM. I DO FULLY UNDERSTAND X Y AND Z AXIS *****
Re: STRANGE ISSUE WITH CROP COORDINATES
Posted: 2011-02-26T16:06:48-07:00
by fmw42
crop_0x300+0+300.jpg. It produced a 300 pixel horizontal band across the entire source image and not starting at 0,0
0x300+0+300 is NOT a 300x300 region --- this is 0 width and 300 y offset from the top left
you cannot use a size of 0 for Width
Re: STRANGE ISSUE WITH CROP COORDINATES
Posted: 2011-02-26T19:24:13-07:00
by goyop
Thanks for the tip. Your comment allowed me to think through the situation and come up with a fix.
FYI, IM does allow you to enter 0x300 and get an output. That is part of the confusion. It gave me a 300 pixel high band that was 1600 pixels wide using the command that you quoted. Try it if you like but I was putting in all sorts of erroneous values and getting output. Not the output I wanted but output.
Thanks
Re: STRANGE ISSUE WITH CROP COORDINATES
Posted: 2011-02-26T20:24:32-07:00
by anthony
fmw42 wrote:crop_0x300+0+300.jpg. It produced a 300 pixel horizontal band across the entire source image and not starting at 0,0
0x300+0+300 is NOT a 300x300 region --- this is 0 width and 300 y offset from the top left
you cannot use a size of 0 for Width.
Actually you CAN use a zero width. A zero is nonsensical and so IM replaces it with the virtual canvas width.
So what you get is a strip or row crop across the whole (X wise) length of the image from 0 virtual canvas to the current virtual canvas width. If the image is smaller than or more typically te same size as the virtual canvas (+repage) you will get everything in that strip.
If the image is larger than, or not completely located on its virtual canvas (also a nonsensical situation but could be done usefully on purpose) you are limited to what part of the image is on the virtual canvas according to its actual size and offset.
This is all explained in IM Examples, Crop, Strip Cropping
http://www.imagemagick.org/Usage/crop/#crop_strip
And is also used in the next sections of Quadrant Cropping, and cropping with Negative Offsets.
The virtual canvas is also used to effect 'tile cropping' too.
Re: STRANGE ISSUE WITH CROP COORDINATES
Posted: 2011-02-26T20:39:30-07:00
by fmw42
Well I stand corrected on the fact that 0 width or height can be used, but it seems non-sense to me with no apparent purpose.