Actually it does seem to work just not the way expected perhaps.
Looking at the fuzz option on ImageMagick's site (http://www.imagemagick.org/script/command-line-options.php#fuzz), "The distance can be in absolute intensity units or, by appending % as a percentage of the maximum possible intensity (255, 65535, or 4294967295)."
As it requires a float, the percentage value won't work so it actually one of the max intensity values. In my case, the images I was working with seemed to have max intensity values of 65535. So a fuzz of 6500, for roughly 10%, seemed to do the trick.
The part that might be problematic though is how do you determine the max intensity of a color/image? Using a static 6500 would be fine until I would have to convert an image with a max intensity other than 65535. If it's 255 it would wipe the entire image. Or fall far short on the fuzz with the larger value.
Imagick::paintTransparentImage
(PECL imagick 2.0.0)
Imagick::paintTransparentImage — Cambia cualquier píxel que coincida con el color definido para el relleno
Descripción
Esta función no está documentada actualmente, solamente se encuentra disponible la lista de parámetros.
Cambia cualquier píxel que coincida con el color definido para el relleno.
Parámetros
- target
-
Cambia este color objetivo por el valor de opacidad especificado dentro de la imagen.
- alpha
-
El nivel de transparencia: 1.0 es completamente opaco y 0.0 es completamente transparente.
- fuzz
-
El miembro enfoque de la imagen define cuánta tolerancia es aceptable para considerar que dos colores son el mismo.
Valores devueltos
Devuelve TRUE en caso de éxito.
Errores/Excepciones
Lanza ImagickException en caso de error.
Historial de cambios
| Versión | Descripción |
|---|---|
| 2.1.0 | Ahora se permite que una cadena represente el color como primer parámetro. Versiones anteriores sólo permitían un objeto ImagickPixel. |
Fuzz attribute doesn't work here.
#!/usr/bin/php
<?php
if(!isset($argv[1])) die("input file\n");
$im = new Imagick( $argv[1] );
$im->paintTransparentImage('rgb(246,241,230)', 0.0, 10);
file_put_contents('transparent_'.$argv[1], $im);
?>
Will "remove" only colors that match exactly rgb(246,241,230)
