开发者

PHP imagefilter function problem

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜