I'm fairly new to ImageMagick, but have used some of the command line tool/options to do basic stuff.
I've got a lot of images that have varying amounts of white background (photos of commercial products). I'd like to make the image sizes consistent, which probably isn't too hard. But ideally what I would like to do is remove the white background, then resize the image so that the image is enlarged as much as possible to fit within a given constraint and isn't affected by the background.
In other words, suppose the image is actually 25% white border/background. I'd like to resize that inner 75%, so that the scaled image has no boarder, making the processed image as large as possible given the size constraints, and not wasting image area on borders. Is that possible?
Remove white background and resize
Re: Remove white background and resize
Show an example image; -trim will remove a border.
This artical may be of interest: http://tech.natemurray.com/2007/12/conv ... arent.html
This artical may be of interest: http://tech.natemurray.com/2007/12/conv ... arent.html
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Remove white background and resize
given you know your input size ahead of time:
use convert input -fuzz XX% -trim +repage -resize WIDTHxHEIGHT output
see http://www.imagemagick.org/script/comma ... p#geometry
use convert input -fuzz XX% -trim +repage -resize WIDTHxHEIGHT output
see http://www.imagemagick.org/script/comma ... p#geometry