I have a 640x480 picture that I would like to store as 4 160x120 pictures, for upper left, upper right, lower left, lower right
|---------|--------|
| | |
|------------------|
| | |
| --------|--------|
Divide image into 4 quadrants
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Divide image into 4 quadrants
I believe Bonzo meant (half the image size in the crop)
convert image -crop 320x240 +repage +adjoin result_%d.suffix
The +adjoin would be needed for images such as gif that would normally put them as frames/layers in the same gif rather than separate images. The +repage removes the virtual canvas.
See
http://www.imagemagick.org/Usage/crop/#crop_tile
http://www.imagemagick.org/Usage/crop/#crop_repage
http://www.fmwconcepts.com/imagemagick/ ... .php#crop2
convert image -crop 320x240 +repage +adjoin result_%d.suffix
The +adjoin would be needed for images such as gif that would normally put them as frames/layers in the same gif rather than separate images. The +repage removes the virtual canvas.
See
http://www.imagemagick.org/Usage/crop/#crop_tile
http://www.imagemagick.org/Usage/crop/#crop_repage
http://www.fmwconcepts.com/imagemagick/ ... .php#crop2
Re: Divide image into 4 quadrants
You are right fmw42I believe Bonzo meant (half the image size in the crop)
But looking at the original post again the OP wants the four corners not the image devided into four - 4 160x120 pictures
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Divide image into 4 quadrants
I'm probably totally wrong, but maybe the OP wants to chop his 640x480 image into four images, each 160x120. This would need a resize followed by crop, eg:
convert infile -resize 50% -crop 2x2@ out_%02d.jpg
Or perhaps he wants to replicate his image, like four passport photos.
Any more guesses? Does the winner get a prize?
convert infile -resize 50% -crop 2x2@ out_%02d.jpg
Or perhaps he wants to replicate his image, like four passport photos.
Any more guesses? Does the winner get a prize?
snibgo's IM pages: im.snibgo.com
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Divide image into 4 quadrants
Sorry, I could not make out what he wanted and just took a guess at the easiest thing.Bonzo wrote:You are right fmw42I believe Bonzo meant (half the image size in the crop)
But looking at the original post again the OP wants the four corners not the image devided into four - 4 160x120 pictures
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Divide image into 4 quadrants
It could mean the 4 quadrants around some point...
http://www.imagemagick.org/Usage/crop/#crop_quad
Basically there are a number of ways the request could be answered, and achieved.
http://www.imagemagick.org/Usage/crop/#crop_quad
Basically there are a number of ways the request could be answered, and achieved.
There are lots of ways to skin a cat, and what method you use depends
on what you want that skin for, and how messy you like the results!
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: Divide image into 4 quadrants
Ok, I'll take the prize 4 images 320,240. just a little mixup on my part
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Divide image into 4 quadrants
If you just want the images in the corners (and ignore the rest) you will need to crop them individually.
For example.
convert image.png \
\( -clone 0 -crop 160x120+0+0 +repage \)
\( -clone 0 -gravity NorthEast -crop 160x120+0+0 +repage \)
\( -clone 0 -gravity SouthEast -crop 160x120+0+0 +repage \)
\( -clone 0 -gravity SouthWest -crop 160x120+0+0 +repage \)
-delete 0 image_save_%d.png
That will save four images extracted from just the corners (deleting the original only at the end). In actual fact this is rather like what tile or equal area cropping does internally.
As usual are at other ways to do this too, for example using: -chop, tile cropping, and even equal area cropping with ignored overlap, or quadrent crop, with sub-cropping. Really it depends on what you want and what other things you may need from the source image.
For example.
convert image.png \
\( -clone 0 -crop 160x120+0+0 +repage \)
\( -clone 0 -gravity NorthEast -crop 160x120+0+0 +repage \)
\( -clone 0 -gravity SouthEast -crop 160x120+0+0 +repage \)
\( -clone 0 -gravity SouthWest -crop 160x120+0+0 +repage \)
-delete 0 image_save_%d.png
That will save four images extracted from just the corners (deleting the original only at the end). In actual fact this is rather like what tile or equal area cropping does internally.
As usual are at other ways to do this too, for example using: -chop, tile cropping, and even equal area cropping with ignored overlap, or quadrent crop, with sub-cropping. Really it depends on what you want and what other things you may need from the source image.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/