问题
PHP Imagemagick API has a vignette function: http://www.php.net/manual/en/imagick.vignetteimage.php
Great, but how do I get it with black color?
回答1:
Vignette's will default to the given image's background color. Altering this color is as simple as setting the image's background color before transforming the image with the Vignette effect.
<?php
$img = new Imagick("source.png");
$img->setImageBackgroundColor("black");
$img->vignetteImage(-5.0,15.0,15,15);
$img->writeImage("source_vignette.png");
$img->destroy();
exit();
Better yet. Use the ImagickPixel object for increased flexibility within your application.
<?php
$img = new Imagick("source.png");
$pixel = new ImagickPixel();
for($i=0;$i < 1; $i += 0.1) {
$pixel->setHSL($i,0.5,0.5);
$img->setImageBackgroundColor($pixel);
$img->vignetteImage(-5.0,15.0,15,15);
$img->writeImage("source_vignette_$i.png");
}
$pixel->destroy();
$img->destroy();
exit();
来源:https://stackoverflow.com/questions/17846665/black-color-of-imagemagick-vignette