Page 1 of 1

bg_removal script usage example?

Posted: 2017-11-01T03:39:37-07:00
by phraktle
Hi,

I'm trying to use the bg_removal script on an image with a white background, for example this one: http://goo.gl/PQAnLs

The following simple floodfill method yields the expected transparency:

Code: Select all

convert foo.jpg -bordercolor white -border 1x1 -alpha set -channel RGBA -fuzz 3% -fill none -floodfill +0+0 white -shave 1x1  -format png foo.png
However, with bg_removal I don't seem to get any transparency. I've tried various parameters with no luck, for example:

Code: Select all

bg_removal foo.jpg white 10 10 foo.png
Any hints / examples on how to use the bg_removal script properly?

(my ImageMagick version is 7.0.7-8 Q16 x86_64 2017-10-24)

Thanks,
Viktor

Re: bg_removal script usage example?

Posted: 2017-11-01T10:26:45-07:00
by fmw42
What is your platform? What is your version of libpng? (mine is 1.6.29_0)

It works fine for me using IM 7.0.7.8 Q16 Mac OSX. However, there is still shadow showing that has not been turned to white. So you may need to increase the fuzz value.

Code: Select all

magick foo.jpg -bordercolor white -border 1x1 -alpha set -channel RGBA -fuzz 3% -fill none -floodfill +0+0 white -shave 1x1  foo.png
Note I removed -format png, since the output has a png suffix. But it works even with -format png.

If that does not help, try using -draw to do the flood fill

Code: Select all

magick foo.jpg -bordercolor white -border 1x1 -alpha set -channel RGBA -fuzz 3% -fill none -draw "alpha 0,0 floodfill" -shave 1x1  foo.png

Re: bg_removal script usage example?

Posted: 2017-11-01T10:30:35-07:00
by phraktle
The first command works for me as well, it is the bg_removal script I'm having no luck with...

My platform is MacOSX as well.

Re: bg_removal script usage example?

Posted: 2017-11-01T10:51:43-07:00
by fmw42
That script was written by Anthony Thyssen on 3 July 2009. So it is likely using very old IM 6 syntax and probably does not work on IM 7. Its code would have to be made compatible with IM 7.

See http://www.imagemagick.org/Usage/masking/#semi-trans, which is where that script is referenced to replace the code example. Perhaps try the commands in that section.