Heim  >  Artikel  >  Backend-Entwicklung  >  php图片处理函数简单例子

php图片处理函数简单例子

WBOY
WBOYOriginal
2016-07-25 08:51:511027Durchsuche
  1. //header('Content-Type:text/html;charset=utf-8');

  2. //图像处理
  3. //1 设置MIME类型 输出类型 text/html 默认是网页类型 可以不写
  4. header('Content-Type:image/png;');
  5. $width = 400;
  6. $height = 400;
  7. //2 创建一个图像区域 宽度 高度
  8. $img = imagecreatetruecolor($width,$height);
  9. //为图像分配颜色 句柄 红 绿 烂
  10. $blue = imagecolorallocate($img,0,102,255);
  11. //填充颜色 资源句柄 x轴 y轴 颜色
  12. imagefill($img,0,0,$blue);
  13. //继续创建颜色
  14. $while = imagecolorallocate($img,255,255,255);
  15. //画一个线条 句柄 x开始 y开始 x结束 y结束 颜色
  16. imageline($img,60,90,90,60,$while);
  17. //打印图片信息
  18. getimagesize($img);
  19. //绘制文本 句柄 字体大小 x轴 y轴 内容 颜色

  20. imagestring($img,5,0,0,'wwwww',$while);
  21. //载入图片 list() 这个函数不错
  22. imagecreatefrompng('22.png');
  23. //原图从新采样 拷贝到新图上
  24. //新图句柄 原图句柄 新图xy 原图 xy 新图长高 原图长高
  25. imagecopyresampled($img,$yuan,40,40,0,0,$_width,$_height,$width,$height);
  26. //输出图片
  27. imagepng($img);
  28. //销毁句柄
  29. imagedestroy($img);
  30. ?>
复制代码


Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn