Page 1 of 1

Replace background colour to any hex code

Posted: 2016-02-29T06:05:19-07:00
by joshuafinny
I have a set of images in a white or off white background. I want to convert the background to a particular hex value (#f1f0ee).

Tried using convert image -fuzz XX% -fill red -opaque white result

The problem here is, it will consider everything white, even parts of the product. Also, the edges need refinement, which does not happen using the above. I would like to perform this action in bulk.

Re: Replace background colour to any hex code

Posted: 2016-02-29T08:34:06-07:00
by Bonzo
I found this interesting post a few years ago: http://tech.natemurray.com/2007/12/conv ... arent.html

Re: Replace background colour to any hex code

Posted: 2016-02-29T10:47:04-07:00
by fmw42
It might help, if you provide an example image. Also always provide your IM version and platform, since syntax may differ.

Re: Replace background colour to any hex code

Posted: 2016-03-01T05:25:02-07:00
by joshuafinny
fmw42 wrote:It might help, if you provide an example image. Also always provide your IM version and platform, since syntax may differ.
IM Version 6.9.4
Windows Platform

Sample Image:
http://i.imgur.com/4Htli6m.jpg

Re: Replace background colour to any hex code

Posted: 2016-03-01T10:12:19-07:00
by fmw42
Try this:

Code: Select all

convert 4Htli6m.jpg -fuzz 1% -fill "#f1f0ee" -opaque white result.jpg

Re: Replace background colour to any hex code

Posted: 2016-03-09T01:36:37-07:00
by joshuafinny
fmw42 wrote:Try this:

Code: Select all

convert 4Htli6m.jpg -fuzz 1% -fill "#f1f0ee" -opaque white result.jpg
Great!! Thanks!