Tried to use *floodfill* to remove background and make it transparent but failed to work.
I downloaded the latest MagickWand php extension 1.0.7 and compiled with ImageMagick 6.4.4.
However, I find it frustrating to get *Floodfill* kinds of functions working? The image after calling MagickFloodfillPaintImage() remains the same even with a large fuzz factor. I've also tried the PHP Imagick
extension(http://us2.php.net/imagick), still have the same problem.
Am I missing something here? I have been scratching my head for days to figure out this problem. Any help is highly
appreciated. Thanks a lot.
-peter
convert --version
Version: ImageMagick 6.4.4 2008-10-08 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2008 ImageMagick Studio LLC
// code sample using MagicWand PHP extension
<?php
$wand = NewMagickWand();
MagickReadImage($wand, 'test.png');
MagickFloodfillPaintImage($wand, NewPixelWand('transparent'), 50, NewPixelWand('white'), 10, 10);
echo MagickEchoImageBlob($wand);
?>
// code sampe using Imagick PHP extension
<?
$im = new Imagick('test.png');
$im->paintFloodfillImage(new ImagickPixel('transparent'), 50, new ImagickPixel('white'), 10, 10);
echo $im;
?>
MagickFloodfillPaintImage cannot remove the background
-
- Posts: 1015
- Joined: 2005-03-21T21:16:57-07:00
Re: MagickFloodfillPaintImage cannot remove the background
There is an optional seventh argument to this function which specifies the channel(s) which are affected by the floodfill. I presume that the default is just the RGB channels, so the 'transparent' colour won't work. I don't know how to specify it in PHP but you need the equivalent of RGBA.MagickFloodfillPaintImage($wand, NewPixelWand('transparent'), 50, NewPixelWand('white'), 10, 10);
See http://www.magickwand.org/MagickFloodfi ... Image.html
Note to Anthony: it would be useful (to me, anyway ) to have a reminder in the floodfill examples (http://www.imagemagick.org/Usage/color/#floodfill) that '-channel rgba' is needed when filling with any amount of transparency. And in the last sentence of that section, the reference to Transparency Masking is a dead link.
Pete