So i have a set of chess pieces I'm pulling out of a modeling application.
I'd like to be able to crop them into their individual chess pieces.
Because they aren't sized uniformly, its difficult to crop with image magick and get the size of each image perfectly.
The images come out to about 105x140, which i have to resize to 160x160. (not stretching the image, just filling in the area, similar to Canvas in photoshop)
Anyways, I'm trying to see if I can center the content inside of the image when I fill in this area to make it 160x160.
Tried the -gravity center but that doesn't see to be the exact thing I need.
Any thoughts, I might have to rethink this approach :-\
Centering Content when filling whitespace in image.
-
- Posts: 2
- Joined: 2012-08-24T14:42:10-07:00
- Authentication code: 67789
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Centering Content when filling whitespace in image.
It would be best to see an example image. Can you post a link?
Otherwise, do a fuzzy trim and be sure to remove the virtual canvas with +repage. Then resize and then pad with some background color to fill the area if the cropped image is not square. (Unless you would rather crop the image to square rather than padding it)
Some thing like
convert inputimage -fuzz XX% -trim +repage -resize 160x160 -gravity center -background somecolor -extent 160x160 resultimage
see
http://www.imagemagick.org/Usage/thumbnails/#pad
http://www.imagemagick.org/Usage/crop/#crop_repage
http://www.imagemagick.org/script/comma ... s.php#fuzz
Otherwise, do a fuzzy trim and be sure to remove the virtual canvas with +repage. Then resize and then pad with some background color to fill the area if the cropped image is not square. (Unless you would rather crop the image to square rather than padding it)
Some thing like
convert inputimage -fuzz XX% -trim +repage -resize 160x160 -gravity center -background somecolor -extent 160x160 resultimage
see
http://www.imagemagick.org/Usage/thumbnails/#pad
http://www.imagemagick.org/Usage/crop/#crop_repage
http://www.imagemagick.org/script/comma ... s.php#fuzz
-
- Posts: 2
- Joined: 2012-08-24T14:42:10-07:00
- Authentication code: 67789
Re: Centering Content when filling whitespace in image.
I'll post right after I get it working, looks like fuzzy trim was the terminology I was missing.
Thanks for the direction!
Thanks for the direction!