php图形图像处理

WBOY
Libérer: 2016-07-25 08:42:43
original
1023 Les gens l'ont consulté
  1. header("content-type:image/jpeg");
  2. /*一、简单的图像输出*/
  3. $im = imagecreate(60,40);
  4. $pink = imagecolorallocate($im,35, 25,220);
  5. imagejpeg($im);
  6. //imagestring($im,16, 200, 200,"I LOVE YOU",);
  7. /* 二、将字符串写入到图片中 */
  8. //载入图片
  9. $me=imagecreatefromjpeg("../../images/3.jpg");
  10. //设置字体颜色
  11. $text_color = imagecolorallocate($me, 255,84,0);
  12. //设置的字体的位置
  13. $font = "C:\Windows\Fonts\simkai.ttf";
  14. //要写入的字符串
  15. $str = iconv('GBK',"UTF-8", "php开发...");
  16. //将字符串写入到图片中
  17. imagettftext($me,20,0,50,50, $text_color,$font, $str);
  18. //输出图片
  19. imagejpeg($me);
  20. //释放资源
  21. imagedestroy($me);
复制代码

  1. session_start();
  2. header("content-type:image/jpeg");
  3. //验证码
  4. //图像宽度
  5. $image_width =65;
  6. //图像高度
  7. $image_height =45;
  8. //设置随机数的种子
  9. //srand(microtime()*1000);
  10. for ($i=0;$i $new_str .=dechex(rand(0, 100));
  11. }
  12. $_SESSION[code]=$new_str;
  13. $image = imagecreate($image_width, $image_height);
  14. imagecolorallocate($image,rand(0,255), rand(0,255),rand(0,255));
  15. for ($i=0;$i $font = mt_rand(3, 8);//生成随机字体大小
  16. $x = mt_rand(3,10)+$image_width*$i/4;
  17. $y = mt_rand(3,$image_height/4);
  18. $color = imagecolorallocate($image,mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));
  19. imagestring($image, $font, $x, $y,$_SESSION[code][$i], $color);
  20. }
  21. imagepng($image);
  22. imagedestroy($image);
复制代码

图像处理, php


Étiquettes associées:
source:php.cn
Déclaration de ce site Web
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn
Tutoriels populaires
Plus>
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal
À propos de nous Clause de non-responsabilité Sitemap
Site Web PHP chinois:Formation PHP en ligne sur le bien-être public,Aidez les apprenants PHP à grandir rapidement!