【问题标题】:How can I brighten/darken an image in PHP?如何在 PHP 中使图像变亮/变暗?
【发布时间】:2017-08-24 04:43:21
【问题描述】:

我想我应该能够使用 GD 来使 PHP 中的图像变亮或变暗,但找不到任何信息。这不可能吗?

【问题讨论】:

  • 抱歉,今天过得不好……

标签: php image image-processing gd


【解决方案1】:

可以使用PHP5及以上提供的imagefilter函数。

bool imagefilter ( resource $image , int $filtertype [, int $arg1 [, int $arg2 [, int $arg3 [, int $arg4 ]]]] )

您应该使用具有从-255255 的值的IMG_FILTER_BRIGHTNESS 来使图像变亮/变暗。

PHP Manual

手册中的示例

<?php
$im = imagecreatefrompng('sean.png');

if($im && imagefilter($im, IMG_FILTER_BRIGHTNESS, 20))
{
    echo 'Image brightness changed.';

    imagepng($im, 'sean.png');
    imagedestroy($im);
}
else
{
    echo 'Image brightness change failed.';
}
?>

【讨论】:

    猜你喜欢
    • 2011-11-15
    • 1970-01-01
    • 2012-01-31
    • 2020-06-09
    • 2017-12-27
    • 2013-01-09
    • 2021-02-12
    • 1970-01-01
    • 2018-09-25
    相关资源
    最近更新 更多