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?
Cropping images into multiple equal Images
-
- Posts: 3
- Joined: 2016-05-06T04:55:23-07:00
- Authentication code: 1151
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Cropping images into multiple equal Images
convert in.jpg -crop 5x5@ +repage out_%02d.png
snibgo's IM pages: im.snibgo.com
-
- Posts: 3
- Joined: 2016-05-06T04:55:23-07:00
- Authentication code: 1151
Re: Cropping images into multiple equal Images
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"
FOR %G IN ("*.jpeg") DO convert "%G" -crop 5x5@ +repage "output\%G"
-
- Posts: 3
- Joined: 2016-05-06T04:55:23-07:00
- Authentication code: 1151
Re: Cropping images into multiple equal Images
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"
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"
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Cropping images into multiple equal Images
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:
I'm not sure if the first "+repage" is needed.
Code: Select all
FOR %G IN ("*.jpg") DO convert "%G" -crop 250x250+0+0 +repage -crop 5x5@ +repage "output\%G"
snibgo's IM pages: im.snibgo.com