开发者

PHP imagefilter function problem

开发者 https://www.devze.com 2023-02-17 18:47 出处:网络
I have a problem with the imagefilter function I get the first example to work but not the second or third examples to work can some one help me figure out what I am doing wrong?

I have a problem with the imagefilter function I get the first example to work but not the second or third examples to work can some one help me figure out what I am doing wrong?

Example 1 will work.

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

if($im && imag开发者_开发问答efilter($im, IMG_FILTER_GRAYSCALE))
{
    echo 'Image converted to grayscale.';

    imagepng($im, 'dave.png');
}
else
{
    echo 'Conversion to grayscale failed.';
}

imagedestroy($im);
?>

Example 2 wont work

<?php
if(!file_exists('dw-bw.png')) {
  $img = imagecreatefrompng('dw-manipulate-me.png');
  imagefilter($img,IMG_FILTER_GRAYSCALE);
  imagepng($img,'db-bw.png');
  imagedestroy($img);
}
?>

Example 3 wont work.

<?php
$image = imagecreatefrompng("space.png");
imagefilter($image, IMG_FILTER_BRIGHTNESS, 50);
header("content-type: image/png");
imagepng($image);
imagedestroy($image);
?>


the original image has no changes what so ever Because you write into a different file, dw-manipulate-me.png -> db-bw.png - and only if the db-bw.png file does not exist yet.

0

精彩评论

暂无评论...
验证码 换一张
取 消