AspJpeg 的简单使用

义乌立天网络在义乌网站建设中常遇到客户需求产品图片加水印的情况,PHP实现起来相对容易一些,ASP实现起来相对麻烦,需要ASPJPEG的支持,这就要求服务器上同时按装相关组件的支持!

1)如何用AspJpeg组件生成图片缩略图? 
<%  
Set Jpeg = Server.CreateObject("Persits.Jpeg")    ’创建实例 
Path = Server.MapPath("../images/apple.jpg")        ’处理图片路径 
Jpeg.Open Path                ’打开图片 
’调整宽度和高度为原来的50% 
Jpeg.Width = Jpeg.OriginalWidth / 2 
Jpeg.Height = Jpeg.OriginalHeight / 2 
Jpeg.Save Server.MapPath("apple_small.jpg")        ’保存图片到磁盘 
Jpeg.Close:Set Jpeg = Nothing 
%>  


2)如何用AspJpeg组件生成图片水印? 
<%  
Set Jpeg = Server.CreateObject("Persits.Jpeg")  
Jpeg.Open Server.MapPath("images/dodge_viper.jpg")  
开始写文字  
Jpeg.Canvas.Font.Color = &000000’’ red 颜色  
Jpeg.Canvas.Font.Family = "Courier New" 字体  
Jpeg.Canvas.Font.Bold = True 是否加粗  
Jpeg.Canvas.Print 10, 10, "Copyright (c) XYZ, Inc."  
打印坐标x 打印坐标y 需要打印的字符  
以下是对图片进行边框处理  
Jpeg.Canvas.Pen.Color = &H000000’’ black 颜色  
Jpeg.Canvas.Pen.Width = 2 画笔宽度  
Jpeg.Canvas.Brush.Solid = False 是否加粗处理  
Jpeg.Canvas.Bar 1, 1, Jpeg.Width, Jpeg.Height  
起始X坐标 起始Y坐标 输入长度 输入高度  
Jpeg.Save Server.MapPath("images/dodge_viper_framed.jpg") 保存  
%> 

3)如何用AspJpeg组件进行图片切割? 
AspJpeg 1.1+ is also capable of cutting off edges from, or cropping, the resultant thumbnails via the method Crop(x0, y0, x1, y1). The size of the cropped image is specified by the coordinates of the upper-left and lower-right corners within the resultant thumbnail, not the original large image.  
<% 
Set Jpeg = Server.CreateObject("Persits.Jpeg") 
Jpeg.Open Server.MapPath("t.jpg") 
jpeg.Crop 20, 30, jpeg.Width - 20, jpeg.Height - 10  
jpeg.save Server.mappath("tt.jpg") 
Response.write("<img src=tt.jpg>") 
%> 





文章来自: 本站原创
引用通告地址: http://www.eobo.cn/seoblog/trackback.asp?tbID=46
Tags:
评论: 0 | 引用: 0 | 查看次数: 8947
发表评论
你没有权限发表留言!