Page 1 of 1

Cutting x pixels from an image

Posted: 2013-03-24T20:51:26-07:00
by adamsilver
Why this is creating many images instead of just two?

Code: Select all

convert input-image.jpg -crop 28x +repage monet_vertical_%d.jpg
I want to get two images; 28 pixels from the base and another image with what's left.

Please help.

Re: Cutting x pixels from an image

Posted: 2013-03-24T21:19:57-07:00
by fmw42
It is doing tile cropping and the part you specified is not half of the image.

Because you are doing tile cropping and you have specified only a small part of the image. It will try to crop out every section that is 28 pixels by full height.

I do not think you can do unequal tile cropping to get only two sections.

To get only two sections, you must split in half, so you can do -crop 50%x100%+0+0 and get two halves.

But you cannot do -crop 25%x100%+0+0 unless you want 4 parts.

To do what you want, you need to do two separate one section crops.

convert image -crop 28x+0+0 +repage output1
convert image -crop WWx+0+0 +repage output2

where WW=W-28

see
http://www.imagemagick.org/Usage/crop/#crop_tile

and the whole section about cropping at
http://www.imagemagick.org/Usage/crop/#crop

Re: Cutting x pixels from an image

Posted: 2013-03-24T23:10:07-07:00
by anthony
you can also use -chop to get the second half of the image.

Code: Select all

convert image -crop 28x0+0+0 +repage output1
convert image -chop 28x0+0+0  output2
or use an alternative -chop using -crop technique
See Chop, removing rows, columns and edges
http://www.imagemagick.org/Usage/crop/#chop

Code: Select all

convert image -crop 28x+0+0 +repage output1
convert image -crop 0x0+28+0 +repage output2

Re: Cutting x pixels from an image

Posted: 2013-03-25T10:31:02-07:00
by adamsilver
Thank you guys. Anthony's first method worked for me.

Code: Select all

	convert $f -gravity South  -crop 0x28+0+0 +repage label.jpg
	convert $f -gravity South  -chop  0x28  not-labeled.jpg