计算并重新设置各调色板索引
手边没有photoshop,不知道你要什么效果
相关函数
ImageColorsTotal: 计算图的颜色数。 
ImageColorsForIndex: 取得色表上指定索引的颜色。 
ImageColorSet: 设定色表上指定索引的颜色。 各色的取值范围是0-255

解决方案 »

  1.   

    你要这样的效果?
    <?php
    $image = "images/csdn.gif";
    $imgstream = file_get_contents($image);
    $im = imagecreatefromstring($imgstream);for($i=0;$i<ImageColorsTotal($im);$i++) {
      $c = ImageColorsForIndex($im,$i);
      $c[red] = 0xff & ~$c[red];
      $c[green] = 0xff & ~$c[green];
      $c[blue] = 0xff & ~$c[blue];
      ImageColorSet($im,$i,$c[red],$c[green],$c[blue]);
    }
    header("Content-type: image/gif");
    imagegif($im);
    ?>在gd2中增加了很多函数名以alpha结束的函数,这个alpha就是通道。你不会没有用过photoshop的photoshop处理图片吧?
      

  2.   

    to  xuzuning(唠叨)  你那一招对jpg没有效果 ,另外,有没有现成的将图片水平镜像,旋转90度等的函数啊?
      

  3.   

    这个自己处理啊
    很简单的.
    唠叨的办法是修改调色板,所以只对gif有效.
    如果是jpg,只能逐像素取反了
      

  4.   

    那你可以先转换成gif再处理嘛
      

  5.   

    <?php
    /**
    flip 图象翻转
    **/$image = "images/csdn.gif"; // 原图
    $imgstream = file_get_contents($image);
    $im = imagecreatefromstring($imgstream);$thumbw = imagesx($im); // 原图宽
    $thumbh = imagesy($im); // 原图高if(function_exists("imagecreatetruecolor"))
      $dim = imagecreatetruecolor($thumbw, $thumbh); // 创建目标图gd2
    else
      $dim = imagecreate($thumbh, $thumbw); // 创建目标图gd1
    for($x=0;$x<$thumbw;$x++)
      for($y=0;$y<$thumbh;$y++) {
    //    imagecopyresized($dim,$im,$thumbw-$x-1,$y,$x,$y,1,1,1,1); //水平翻转
        imagecopyresized($dim,$im,$x,$thumbh-$y-1,$x,$y,1,1,1,1); //垂直翻转
      }
    header ("Content-type: image/jpeg");
    imagejpeg ($dim);
    ?>
    逐线操作,有点慢
      

  6.   

    php5 里面多了一个函数,这个可以实现你的效果imagefilter --  Applies a filter to an image
    Description
    bool imagefilter ( resource src_im, int filtertype [, int arg1 [, int arg2 [, int arg3]]] )imagefilter() applies the filter filtertype to the image, using arg1, arg2 and arg3 where necessary.filtertype can be one of the following:    *      IMG_FILTER_NEGATE: Reverses all colors of the image.
        *      IMG_FILTER_GRAYSCALE: Converts the image into grayscale.
        *      IMG_FILTER_BRIGHTNESS: Changes the brightness of the image. Use arg1 to set the level of brightness.
        *      IMG_FILTER_CONTRAST: Changes the contrast of the image. Use arg1 to set the level of contrast.
        *      IMG_FILTER_COLORIZE: Like IMG_FILTER_GRAYSCALE, except you can specify the color. Use arg1, arg2 and arg3 in the form of red, blue, green. The range for each color is 0 to 255.
        *      IMG_FILTER_EDGEDETECT: Uses edge detection to highlight the edges in the image.
        *      IMG_FILTER_EMBOSS: Embosses the image.
        *      IMG_FILTER_GAUSSIAN_BLUR: Blurs the image using the Gaussian method.
        *      IMG_FILTER_SELECTIVE_BLUR: Blurs the image.
        *      IMG_FILTER_MEAN_REMOVAL: Uses mean removal to achieve a "sketchy" effect.
        *      IMG_FILTER_SMOOTH: Makes the image smoother. Use arg1 to set the level of smoothness.     注: &#65533;&#65533;&#65533;&#65533;&#65533;&#65533; PHP &#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533; GD &#65533;&#65533;&#1211;&#65533;&#65533;&#65533;&#65533;&#65533;&#689;&#65533;&#65533;&#65533;á&#65533;&#65533;&#65533;&#65533;&#633;&#65533;&#65533;&#65533;&#65533; TRUE&#65533;&#679;&#65533;&#65533;&#65533;&#65533;&#65533; FALSE&#65533;例子 1. imagefilter() grayscale example
    <?php
    $im = imagecreatefrompng('dave.png');
    if ($im && imagefilter($im, IMG_FILTER_GRAYSCALE)) {
       echo 'Image converted to grayscale.';
       imagepng($im, 'dave.png');
    } else {
       echo 'Conversion to grayscale failed.';
    }imagedestroy($im);
    ?>例子 2. imagefilter() brightness example
    <?php
    $im = imagecreatefrompng('sean.png');
    if ($im && imagefilter($im, IMG_FILTER_BRIGHTNESS, 20)) {
       echo 'Image brightness changed.';
       imagepng($im, 'sean.png');
    } else {
       echo 'Image brightness change failed.';
    }imagedestroy($im);
    ?>例子 3. imagefilter() colorize example
    <?php
    $im = imagecreatefrompng('philip.png');/* R, G, B, so 0, 255, 0 is green */
    if ($im && imagefilter($im, IMG_FILTER_COLORIZE, 0, 255, 0)) {
       echo 'Image successfully shaded green.';
       imagepng($im, 'philip.png');
    } else {
       echo 'Green shading failed.';
    }imagedestroy($im);
    ?>