asp.net(C#)上传图片时添加水印问题
发布网友
发布时间:2022-04-19 04:18
我来回答
共3个回答
热心网友
时间:2022-04-19 05:47
public string GetCopyrightByImg(string path, string fileName, string Path_sypf)
{
FileInfo file = new FileInfo(path+fileName);
file.MoveTo(path + "diagram_" + fileName);
path = path.Replace("/", "\\");
string FileName = fileName;
if (File.Exists(path + FileName) == false)
{
System.Drawing.Image oldimage = System.Drawing.Image.FromFile(path + "diagram_" + fileName);
System.Drawing.Image copyImage = System.Drawing.Image.FromFile(Path_sypf);
System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(oldimage);
g.DrawImage(copyImage, new System.Drawing.Rectangle(oldimage.Width - copyImage.Width-10,
oldimage.Height - copyImage.Height-10, copyImage.Width, copyImage.Height),
0, 0, copyImage.Width, copyImage.Height, System.Drawing.GraphicsUnit.Pixel);
string YFileName = FileName;
switch (FileName.Split(".".ToCharArray())[1].ToUpper())
{
case "JPEG":
oldimage.Save(path + YFileName, System.Drawing.Imaging.ImageFormat.Jpeg);
break;
case "JPG":
oldimage.Save(path + YFileName, System.Drawing.Imaging.ImageFormat.Jpeg);
break;
case "GIF":
oldimage.Save(path + YFileName, System.Drawing.Imaging.ImageFormat.Gif);
break;
case "PNG":
oldimage.Save(path + YFileName, System.Drawing.Imaging.ImageFormat.Png);
break;
case "BMP":
oldimage.Save(path + YFileName, System.Drawing.Imaging.ImageFormat.Bmp);
break;
default:
oldimage.Save(path + YFileName, System.Drawing.Imaging.ImageFormat.Jpeg);
break;
}
copyImage.Dispose();
g.Dispose();
oldimage.Dispose();
File.Delete(path + "diagram_" + fileName);
return YFileName;//返回处理后的图片名称
}
else//如果图片已经存在则返回""
{
return "";
}
}
热心网友
时间:2022-04-19 07:05
通过。net画板类库,在你的图片上会出自己水印。在这之前你会得到图片大小。
热心网友
时间:2022-04-19 08:40
文字水印还是图片水印?