Вход
Регистрация
PHP коды
| Преобразование изображения в черно-белое на PHP
function MakeColoursGrey($im,$col){ $total=ImageColorsTotal($im); for($i=0;$i<$total;$i++){ $old=ImageColorsForIndex($im,$i); #trying to keep proper saturation when converting $commongrey=(int)($old['red']+$old['green']+$old['blue'])/3; if(!$col){ ImageColorSet($im,$i,$commongrey,$commongrey,$commongrey); }elseif($col==1){ ImageColorSet($im,$i,$commongrey,0,0); }elseif($col==2){ ImageColorSet($im,$i,0,$commongrey,0); }elseif($col==3){ ImageColorSet($im,$i,0,0,$commongrey); } } } $img=imagecreatefromgif($src); #change the colours to grey MakeColoursGrey($img,$col); #send the http header, this outputs an image of type gif Header("Content-Type: image/gif"); #send the image ImageGif($img);
Онлайн: 1
Реклама
Наш надёжный хостинг партнер
Купить рекламу