Page 1 of 1

Remove white background and resize

Posted: 2010-04-27T22:09:15-07:00
by mikeinpdx
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?

Re: Remove white background and resize

Posted: 2010-04-28T00:04:40-07:00
by Bonzo
Show an example image; -trim will remove a border.

This artical may be of interest: http://tech.natemurray.com/2007/12/conv ... arent.html

Re: Remove white background and resize

Posted: 2010-04-28T09:07:31-07:00
by fmw42
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

Re: Remove white background and resize

Posted: 2010-04-28T10:36:40-07:00
by mikeinpdx
Thanks! That's exactly what I needed.