asp.net 图片水印+文字水印


public void AddWaterPic()

//图片水印
string bg = Request.MapPath("~/images/bg.jpg");//背景图
string newPath = Request.MapPath("~/newImages/");//保存路径
string shuiyin= Request.MapPath("~/images/scrollBlock.jpg");//水印图片
System.Drawing.Image image = System.Drawing.Image.FromFile(bg); //取出背景图片
System.Drawing.Image img = System.Drawing.Image.FromFile(shuiyin);//取出水印图片

Graphics g = Graphics.FromImage(image);

Rectangle rectbg = new Rectangle(932, 728, image.Width, image.Height); //水印的坐标宽932,高728

g.DrawImage(img, rectbg , 0, 0, img.Width, img.Height, GraphicsUnit.Pixel); //在指定位置并且按大小绘制水印图片

//文字水印
DateTime dt = Convert.ToDateTime(Date);
g.DrawString(dt.ToString("yyyy年MM月dd日"), f, b, 934, 730);
newImageName = (dt.ToString("yyyyMMddhhmmssms") + ".jpg");
System.Drawing.Image cover = System.Drawing.Image.FromFile(newPath + newImageName);
Response.ContentType = "image/jpeg";//设置输出类型为JPEG图片
cover.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);//将修改的图片存入输出流
cover.Dispose();//输出图片到客户端
Response.End();

  

asp.net 图片水印+文字水印

时间: 2024-12-10 00:45:37

asp.net 图片水印+文字水印的相关文章

php给图片加文字水印

<? php /*给图片加文字水印的方法*/ $dst_path = 'http://f4.topitme.com/4/15/11/1166351597fe111154l.jpg'; $dst = imagecreatefromstring(file_get_contents($dst_path)); /*imagecreatefromstring()--从字符串中的图像流新建一个图像,返回一个图像标示符.其表达了从给定字符串得来的图像 图像格式将自己主动监測,仅仅要php支持jpeg,png,

php 图片添加文字水印 以及 图片合成(微信快码传播)

1.图片添加文字水印: $bigImgPath = 'backgroud.png'; $img = imagecreatefromstring(file_get_contents($bigImgPath)); $font = 'msyhl.ttc';//字体 $black = imagecolorallocate($img, 0, 0, 0);//字体颜色 RGB $fontSize = 20; //字体大小 $circleSize = 60; //旋转角度 $left = 50; //左边距

php给图片添加文字水印方法汇总

在php中要给图片加水印我们需要给php安装GD库了,这里我们不介绍GD库安装,只介绍怎么利用php给图片添加文字水印的4种方法的汇总.有需要的小伙伴可以参考下. 1: 面向过程的编写方法 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 //指定图片路径 $src = '001.png'; //获取图片信息 $info = getimagesize($src); //获取图片扩展名 $type = image_type_to_ex

php图片添加文字水印方法汇总

方法一: <?php header("content-type:text/html;charset=utf-8"); //指定图片路径 $src = "img/a.png"; //获取图片信息 $info = getimagesize($src); //获取图片扩展名 $type = image_type_to_extension($info[2],false); // echo $type; // exit; //动态的把图片导入内存中 $fun = &qu

php给图片添加文字水印

PHP对图片的操作用到GD库,这里我们介绍如何给图片添加文字水印. 大致分为四步: 1.打开图片 2.操作图片 3.输出图片 4.销毁图片 下面我们上代码来具体讲解每步的实现过程: <?php /*打开图片*/ //1.配置图片路径 $src = "bg.jpg"; //2.获取图片信息 $info = getimagesize($src); //3.通过编号获取图像类型 $type = image_type_to_extension($info[2],false); //4.在

php 图片加水印文字水印

/*给图片加文字水印的方法*/ $dst_path = 'http://f4.topitme.com/4/15/11/1166351597fe111154l.jpg';//保证路径正确 $dst = imagecreatefromstring(file_get_contents($dst_path)); /*imagecreatefromstring()--从字符串中的图像流新建一个图像,返回一个图像标示符,其表达了从给定字符串得来的图像 图像格式将自动监测,只要php支持jpeg,png,gi

在PHP中给图片添加文字水印

<?php if (function_exists('imagepng')) { dir('GD库不存在'); } //图片路径 $imagePath = './img/a.jpg'; //获取文件类型 $imageInfo = getimagesize($imagePath); $imageExtension = image_type_to_extension($imageInfo[2], false); //获取图片 $func = 'imagecreatefrom' . $imageExt

PHP图片加文字水印和图片水印方法

文字水印 $dst_path = 'dst.jpg'; //创建图片的实例$dst = imagecreatefromstring(file_get_contents($dst_path)); //打上文字$font = './simsun.ttc';//字体$black = imagecolorallocate($dst, 0x00, 0x00, 0x00);//字体颜色imagefttext($dst, 13, 0, 20, 20, $black, $font, '快乐编程'); //输出图

图片添加文字水印 和图片水印

<?php /** * @desc 图片处理类 */ class Pic{ private $info; private $res; public $thumb_pic; public function __construct($picPath){ //获取图片信息 $this->info = getimagesize($picPath); //获取图片名 $this->info['type'] = image_type_to_extension($this->info[2],fa