zoukankan      html  css  js  c++  java
  • php给图片加文字水印

    <?

    php /*给图片加文字水印的方法*/ $dst_path = 'http://f4.topitme.com/4/15/11/1166351597fe111154l.jpg'; $dst = imagecreatefromstring(file_get_contents($dst_path)); /*imagecreatefromstring()--从字符串中的图像流新建一个图像,返回一个图像标示符。其表达了从给定字符串得来的图像 图像格式将自己主动监測,仅仅要php支持jpeg,png,gif,wbmp,gd2.*/ $font = './t1.ttf'; $black = imagecolorallocate($dst, 0, 0, 0); imagefttext($dst, 20, 0, 10, 30, $black, $font, 'Hello world!'); /*imagefttext($img,$size,$angle,$x,$y,$color,$fontfile,$text) $img由图像创建函数返回的图像资源 size要使用的水印的字体大小 angle(角度)文字的倾斜角度,假设是0度代表文字从左往右。假设是90度代表从上往下 x,y水印文字的第一个文字的起始位置 color是水印文字的颜色 fontfile,你希望使用truetype字体的路径*/ list($dst_w,$dst_h,$dst_type) = getimagesize($dst_path); /*list(mixed $varname[,mixed $......])--把数组中的值赋给一些变量 像array()一样。这不是真正的函数,而是语言结构,List()用一步操作给一组变量进行赋值*/ /*getimagesize()能获取到什么信息? getimagesize函数会返回图像的全部信息,包含大小。类型等等*/ switch($dst_type){ case 1://GIF header("content-type:image/gif"); imagegif($dst); break; case 2://JPG header("content-type:image/jpeg"); imagejpeg($dst); break; case 3://PNG header("content-type:image/png"); imagepng($dst); break; default: break; /*imagepng--以PNG格式将图像输出到浏览器或文件 imagepng()将GD图像流(image)以png格式输出到标注输出(通常为浏览器),或者假设用filename给出了文件名称则将其输出到文件*/ } imagedestroy($dst); ?>


    钟志远  江苏南京  904727147
  • 相关阅读:
    百度云满速下载原理与方法
    新版知乎登录之post请求
    requests发送post请求的一些疑点
    Python3实现ICMP远控后门(下)之“Boss”出场
    Python3实现ICMP远控后门(中)之“嗅探”黑科技
    Python3实现ICMP远控后门(上)_补充篇
    Python3实现ICMP远控后门(上)
    反射-Class
    希尔排序(java)
    插入排序(java)
  • 原文地址:https://www.cnblogs.com/gccbuaa/p/6921393.html
Copyright © 2011-2022 走看看