ImageMagick小插图的黑色? [英] Black color of ImageMagick vignette?

查看:123
本文介绍了ImageMagick小插图的黑色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

PHP Imagemagick API具有晕影功能:对象可提高应用程序的灵活性。

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


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

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

这篇关于ImageMagick小插图的黑色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆