문제

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?

도움이 되었습니까?

해결책

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();

enter image description here

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();
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top