asp.net生成缩略图及给原始图加水印

ASP.NET(C#)缩略图片,添加文字水印和图片水印 根据用户所上传的图片进行缩略、添加文字水印和图片水印; 立即下载

asp.net生成缩略图及给原始图加水印

 

using System.IO;
using System.Drawing.Imaging;

  private void Button1_ServerClick(object sender, System.EventArgs e)
  {
    Graphics g=null;
    System.Drawing.Image upimage=null;
    System.Drawing.Image thumimg=null;
    System.Drawing.Image simage=null;
    Bitmap outputfile=null;
    try
    {
      string extension = Path.GetExtension(File1.PostedFile.FileName).ToUpper();
      string filename = DateTime.Now.ToString("yyyyMMddhhmmss");
      string smallpath = Server.MapPath(".")+"/smallimg/";
      string bigpath = Server.MapPath(".")+"/bigimg/";
      int width,height,newwidth,newheight;

      System.Drawing.Image.GetThumbnailImageAbort callb =new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback);   
    if(!Directory.Exists(smallpath))
     Directory.CreateDirectory(smallpath);
    if(!Directory.Exists(bigpath))
     Directory.CreateDirectory(bigpath);

    Stream upimgfile = File1.PostedFile.InputStream;
    string simagefile = Server.MapPath("a8logo.jpg"); //要加水印的文件
    simage=System.Drawing.Image.FromFile(simagefile);
    upimage= System.Drawing.Image.FromStream(upimgfile); //上传的图片

    width = upimage.Width;
    height = upimage.Height;
    if(width>height)
    {
     newwidth=200;
     newheight =(int)((double)height/(double)width * (double)newwidth);
    }
    else
    {
     newheight=200;
     newwidth=(int)((double)width/(double)height * (double)newheight);   
    }   
    thumimg = upimage.GetThumbnailImage(newwidth,newheight,callb,IntPtr.Zero);
    outputfile=new Bitmap(upimage);
    g=Graphics.FromImage(outputfile);
    g.DrawImage(simage,new Rectangle(upimage.Width-simage.Width,upimage.Height-simage.Height,upimage.Width,upimage.Height),0,0,upimage.Width,upimage.Height,GraphicsUnit.Pixel);
    
    string newpath = bigpath + filename + extension;     //原始图路径
    string thumpath = smallpath + filename + extension;  //缩略图路径
    outputfile.Save(newpath);
    thumimg.Save(thumpath);
    outputfile.Dispose();
    
   }
   catch(Exception ex)
   {
    throw ex;
   }
   finally
   {
    if(g!=null)
     g.Dispose();
    if(thumimg!=null)
     thumimg.Dispose();
    if(upimage!=null)
     upimage.Dispose();
    if(simage!=null)
     simage.Dispose();
   }
  }
  public bool ThumbnailCallback()
  {
   return false;
  }


基于C#+ASP.NET 实现的功能超强缩略图水印组件源程序代码 功能齐全的.Net缩略图水印组件V2.0正式版,提供图片旋转加水印、图片无损生成、水印文字中文字竖形排列,增加文字纵横排列参数开关、水印图片过滤背景色等功能。 立即下载

相关推荐

ASP.NET图片上传,生成缩略图,加文字、图片水印

内容索引:.NET源码,上传下载,图片上传,水印,生成缩略图  图片上传:生成缩略图,并加文字水印或图片水印,远程图片抓取(保存到本地)支持jpg、gif、bmp、png等,将抓取的图片以日期+原名称命名并保存,支持Html输入远程图片地址。本源码由社区51ASPX提供。   所用组件附带源代码,在VS2005下可顺利编译。

asp.net生成缩略图并给原始图加水印

using System.IO;using System.Drawing.Imaging;  private void Button1_ServerClick(object sender, System.EventArgs e)  {    Graphics g=null;    System.Drawing.Image upimage=null;     System.Drawing.Image

forever10的专栏 892

asp.net实现生成缩略图及给原始图加水印的方法示例

主要介绍了asp.net实现生成缩略图及给原始图加水印的方法,结合具体实例形式分析了asp.net图片的缩略图与水印操作相关实现技巧,需要的朋友可以参考下

asp.net生成缩略图及给原始图加水印和版权信息

using System;using System.IO;using System.Drawing;using System.Drawing.Imaging;namespace A8.Watermark{ ///  ///将上传的图片增加水印及生成缩略图 ///  public class watermark {  ///   /// 水印图  ///   public Bitmap LogoIm

.net天涯 1290

asp.net文件上传功能(单文件,多文件,自定义生成缩略图,水印)

前言 上传功能,是大家经常用到了,可能每一个项目都可以会用到。网上到处都有上传功能的代码。比我写的好的有很多。我这里也仅是分享我的代码。 功能实现点 1.单个文件上传; 2.多个文件上传; 3.对于图片等类型的图像,可以自定义生成缩略图大小; 4.文件服务器扩展。 模式 主要使用的是“模板方法”的设计模式。 本文章的功能优缺点 1.可以自定义生成缩略图的大小,任意定义。对于像微生活运动户外商城(http://sports.8t8x.com/) 、淘宝网等的网站,他们需要上传大量的商品图片时,非常有用。 2.缺点,我对System.Drawing的命名空间不太熟练,生成图像的方法还是从网上抄的,

VFIO框架源码分析(二十一)- IOMMUFD 模式下的 DMA 映射机制

在虚拟化 I/O 的世界里,无论上层管理面(如对象模型、设备绑定)如何重构,数据面最核心的任务始终未变——DMA 映射(DMA Mapping)。即如何建立 Guest Physical Address (GPA) 到 Host Physical Address (HPA) 的映射关系,并将其填入 IOMMU 的硬件页表中,使得直通设备能够正确访问虚拟机内存。在 Legacy VFIO (Type1) 时代,这一职责由承担,它通过ioctl 操作 Container。

qq_36071928的博客 1007

ASP.NET生成缩略图及给原始图加水印

using System.IO;using System.Drawing.Imaging;private void Button1_ServerClick(object sender, System.EventArgs e){Graphics g=null;System.Drawing.Image upimage=null;System.Drawing.Image thumi

zhou00000000的专栏 432

保姆级教程:用rosbag录制和回放你的第一个ROS机器人数据(附C++/Python代码)

本文提供了一份详细的ROS机器人数据录制与回放教程,涵盖从命令行操作到C++/Python编程实现的全流程。通过rosbag工具,开发者可以高效记录和回放机器人运行时的传感器数据和控制指令,适用于故障复现、算法调试等多种场景。教程还包含高级技巧如时间同步和大文件处理,帮助用户快速掌握ROS数据管理核心技能。

weixin_29313239的博客 283

asp.net生成缩略图及给原始图加水印(调试成功)

private void smallpic_Click(object sender, System.EventArgs e)  {    Graphics g=null;    System.Drawing.Image upimage=null;     System.Drawing.Image thumimg=null;     System.Drawing.Image simage=null;

1130

Win10平台下QT6.9.0 OpenCV 4.10.0从入门到精通

我最近开发一个视觉项目,我们从0开始记录在windows 10下 用QT6.9+OpenCV 4.10.0搞定整个项目的开发过程。以抛砖引玉,大家共同进步。

fds111111的博客 1712

利用Matlab实现矩形波导电磁场分布图的绘制

1.利用Matlab实现矩形波导电磁场分布图的绘制;2.学会使用 Matlab 进行数值计算,并绘出相应的图形;通过Matlab 计算并绘出任意时刻金属矩形波导的主模 TE10 模的电磁场分布图。波导尺寸、工作频率及时刻均由外部给定。(1)矩形波导中传输的主模为TE10模。设金属波导尺寸为a*b,TE10模的截止波长为2*a。其电磁场分量可推导表示如下:.......1-1上式中各参量如下:......1-2。

qq_26335381的博客 3058
上一篇: .NET常用功能和代码
下一篇: 用SQLDMO在ASP.NET页面下实现数据库的备份与恢复
SmartJavaer
博客等级 码龄21年 0粉丝 37原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值