国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > ASP > 正文

ASP程序給上傳的圖片增添水印效果!

2020-07-27 13:16:59
字體:
來源:轉載
供稿:網友
ASPJPEG是Persits出品的共享軟件,試用期為30天,您可以在這里下載:http://www.persits.com/aspjpeg.exe。
最新版本號是1.3

=========================================
<%   
    sub   jpegclass(imgurl,fontsize,family,isbold,top,left,content,Horflip)   '調用過程名     

          Dim   Jpeg,font_color,font_size,font_family,f_width,f_height,f_content,f_Horflip   
          '建立實例   
                Set   Jpeg   =   Server.CreateObject("Persits.Jpeg")   
                font_size=10   
                font_family="宋體"   
                f_left=   5   
                f_top=5   

                      if   imgurl<>""   then   
                            Jpeg.Open   Server.MapPath(imgurl)'圖片路徑并打開它   
                      else   
                      response.write   "未找到圖片路徑"   
                      exit   sub     
                      end   if   

                      if   fontsize<>""   then   font_size=fontsize     '字體大小   
                      if   family<>""   then       font_family=family       '字體   
                      if   top<>""   then   f_left=left               '水印離圖片左邊位置   
                      if   left<>""   then   f_top=top         '水印離圖片top位置   
                      if   content=""   then     '水印內容   
                                response.write   "水印什么內容呢,水印不成功!"   
                                exit   sub   
                      else   
                                f_content=content   
                      end   if   

    
                        '   添加文字水印   
                      Jpeg.Canvas.Font.Color   =   &hff0000         '   紅色   
                      Jpeg.Canvas.Font.Family   =   font_family   
                      jpeg.canvas.font.size=     font_size   
                      if   isbold=1     then       
                      Jpeg.Canvas.Font.Bold   =   True     
                      end   if     
    If   Horflip   =   1   Then   
              Jpeg.FlipH   
      'Jpeg.SendBinary   
                    End   If   
                      Jpeg.Canvas.Print   f_left,     f_top,   f_content   

                        '   保存文件   
                      Jpeg.Save   Server.MapPath(imgurl)   

                      '   注銷對象   
                      Set   Jpeg   =   Nothing   
  response.write   "水印成功,圖片上加了  "&content&""   
  end   sub     

  call   jpegclass("apple.jpg",13,"楷體",1,18,18,"你好,這是水印程序",1)   
  %>   

  先下載aspjpeg組建,注冊后使用 

################轉載方法2####################

ASP給圖片加水印是需要組件的...常用的有aspjpeg軟件和中國人自己開發的wsImage軟件,可以上網搜索下載這兩個軟件,推薦使用咱們中國人自己開發的wsImage,畢竟是中文版,容易操作.

注冊組件的方法:

命令提示符下輸入"regsvr32 [Dll路徑]" 就可以了.

圖片添加水印無非就是獲得圖片大小,然后把水印寫上去..ASP代碼只是起個控制組件的作用.用代碼來說明一切吧.

一:獲得圖片大小(這里是用象素值表示的.學PhotoShop的朋友都應該明白)

<%

set obj=server.CreateObject("wsImage.Resize") ''調用組件

obj.LoadSoucePic server.mappath("25.jpg") ''打開圖片,圖片名字是25.jpg

obj.GetSourceInfo iWidth,iHeight 

response.write "圖片寬度:" & iWidth & "<br>" ''獲得圖片寬度

response.write "圖片高度:" & iHeight & "<br>" ''獲得圖片高度

strError=obj.errorinfo 

if strError<>"" then

response.write obj.errorinfo

end if

obj.free

set obj=nothing 

%>

''----------------------------------------------------------------''

二:添加文字水印

<%

set obj=server.CreateObject("wsImage.Resize")

obj.LoadSoucePic server.mappath("25.jpg") ''裝載圖片

obj.Quality=75

obj.TxtMarkFont = "華文彩云" ''設置水印文字字體

obj.TxtMarkBond = false ''設置水印文字的粗細

obj.MarkRotate = 0 ''水印文字的旋轉角度

obj.TxtMarkHeight = 25 ''水印文字的高度

obj.AddTxtMark server.mappath("txtMark.jpg"), "帶你離境", &H00FF00&, 10, 70 

strError=obj.errorinfo ''生成圖片名字,文字顏色即水印在圖片的位置

if strError<>"" then

response.write obj.errorinfo

end if

obj.free

set obj=nothing

%>

''----------------------------------------------------------------''

三:添加圖片水印

<%

set obj=server.CreateObject("wsImage.Resize")

obj.LoadSoucePic server.mappath("25.jpg") ''裝載圖片

obj.LoadImgMarkPic server.mappath("blend.bmp") ''裝載水印圖片

obj.Quality=75 

obj.AddImgMark server.mappath("imgMark.jpg"), 315, 220,&hFFFFFF, 70

strError=obj.errorinfo ''生成圖片名字,文字顏色即水印在圖片的位置

if strError<>"" then

response.write obj.errorinfo

end if

obj.free

set obj=nothing

%>

''----------------------------------------------------------------''

其實給圖片添加水印就這么簡單.然后我在說下WsImage.dll組件的另外兩個主要用法.包括:

剪裁圖片,生成圖片的縮略圖.

還是以我得習慣,用代碼加注釋說明:

剪裁圖片:

<%

set obj=server.CreateObject("wsImage.Resize")

obj.LoadSoucePic server.mappath("25.jpg")

obj.Quality=75

obj.cropImage server.mappath("25_crop.jpg"),100,10,200,200 ''定義裁減大小和生成圖片名字

strError=obj.errorinfo

if strError<>"" then

response.write obj.errorinfo

end if

obj.free

set obj=nothing

%>

詳細注釋:裁減圖片用到了WsImage的CropImage方法.其中定義生成圖片時候,100,10是左上角的裁減點,即離圖片左邊是100象素,頂端10象素.后兩個200代表的是裁減的寬帶和高和高度.

''----------------------------------------------------------------''

生成圖片縮略圖:

<%

set obj=server.CreateObject("wsImage.Resize")

obj.LoadSoucePic server.mappath("25.jpg") ''加載圖片

obj.Quality=75

obj.OutputSpic server.mappath("25_s.jpg"),0.5,0.5,3 ''定義縮略圖的名字即大小

strError=obj.errorinfo

if strError<>"" then

response.write obj.errorinfo

end if

obj.free

set obj=nothing

%>

詳細說明:

產生縮略圖共有四種導出方式: 

(1) obj.OutputSpic server.mappath("25_s.jpg"),200,150,0

200為輸出寬,150為輸出高,這種輸出形式為強制輸出寬高,可能引起圖片變形。

(2) obj.OutputSpic server.mappath("25_s.jpg"),200,0,1

以200為輸出寬,輸出高將隨比列縮放。

(3) obj.OutputSpic server.mappath("25_s.jpg"),0,200,2

以200為輸出高,輸出寬將隨比列縮放。

(4) obj.OutputSpic server.mappath("25_s.jpg"),0.5,0.5,3

第一個0.5表示生成的縮略圖是原圖寬的一半,即表示寬縮小比例。

第二個0.5表示生成的縮略圖是原圖高的一半,即表示高縮小比例。

寬高的縮小比例一致意味著將對原圖進行比例縮小。寬高的縮放比例如果大于1,則對原圖進行放大。 


希望這點技術性文章對你有幫助.


小程序詳細內容和下載地址:http://www.mbsky.com/SoftView/SoftView_38956.html
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 吉安市| 阿坝县| 阿克陶县| 兴宁市| 始兴县| 茶陵县| 河池市| 徐汇区| 广汉市| 调兵山市| 连州市| 平泉县| 星子县| 类乌齐县| 叙永县| 南陵县| 都昌县| 宜春市| 安化县| 卫辉市| 太原市| 宜川县| 福清市| 呼图壁县| 南部县| 榆林市| 阳城县| 惠东县| 平安县| 南京市| 玉龙| 桂平市| 晴隆县| 日土县| 北宁市| 泸溪县| 鄂伦春自治旗| 寿宁县| 盐亭县| 泾阳县| 林周县|