Вход Регистрация
* Sheldon (Adm)

Преобразование изображения в черно-белое на PHP

  1. function MakeColoursGrey($im,$col){
  2. $total=ImageColorsTotal($im);
  3. for($i=0;$i<$total;$i++){
  4. $old=ImageColorsForIndex($im,$i);
  5.  
  6. #trying to keep proper saturation when converting
  7. $commongrey=(int)($old['red']+$old['green']+$old['blue'])/3;
  8. if(!$col){
  9. ImageColorSet($im,$i,$commongrey,$commongrey,$commongrey);
  10. }elseif($col==1){
  11. ImageColorSet($im,$i,$commongrey,0,0);
  12. }elseif($col==2){
  13. ImageColorSet($im,$i,0,$commongrey,0);
  14. }elseif($col==3){
  15. ImageColorSet($im,$i,0,0,$commongrey);
  16. }
  17. }
  18. }
  19.  
  20. $img=imagecreatefromgif($src);
  21.  
  22. #change the colours to grey
  23. MakeColoursGrey($img,$col);
  24.  
  25. #send the http header, this outputs an image of type gif
  26. Header("Content-Type: image/gif");
  27.  
  28. #send the image
  29. ImageGif($img);
» Описание: ...
» Время добавления: 21 Марта 2020 в 00:14
» Посмотров: 1518
» textarea
» Рейтинг: [+0 | -0]
Комментарии [0]
Онлайн: 3
Реклама