Page 1 of 1

Cropping images into multiple equal Images

Posted: 2016-05-06T05:03:30-07:00
by jnewbrough
I have a folder full of hundreds of images and am trying to crop each jpeg into multiple equal sized images. I have tried this but end up with excess little chips from the edges.

Each original image is 256 X 256 pixels and the goal is to crop these into 25 images that are 50 X 50 pixels. I keep getting 6 X 50 pixel images from the edge. Can anyone show me how to make this work correctly?

Re: Cropping images into multiple equal Images

Posted: 2016-05-06T05:06:43-07:00
by snibgo
convert in.jpg -crop 5x5@ +repage out_%02d.png

Re: Cropping images into multiple equal Images

Posted: 2016-05-06T05:14:17-07:00
by jnewbrough
That almost works. It no longer gives me the small edge chips, but that is because it just re-sized the chips to take in the extra pixels. What I'm looking for is even 50 X 50 chips and just ignore the extras on the edges.

FOR %G IN ("*.jpeg") DO convert "%G" -crop 5x5@ +repage "output\%G"

Re: Cropping images into multiple equal Images

Posted: 2016-05-06T06:21:01-07:00
by jnewbrough
It isn't pretty, but I got it.

FOR %G IN ("*.jpg") DO convert "%G" -crop 250x250+0+0 "output\%G"

FOR %G IN ("*.jpg") DO convert "%G" -crop 5x5@ +repage "output\%G"

Re: Cropping images into multiple equal Images

Posted: 2016-05-06T10:12:23-07:00
by snibgo
If you want to crop each image into a single 250x250, then chop that into 25 off 50x50 pieces, you need only one for loop and only one convert:

Code: Select all

FOR %G IN ("*.jpg") DO convert "%G" -crop 250x250+0+0 +repage -crop 5x5@ +repage "output\%G"
I'm not sure if the first "+repage" is needed.