分享你我的心得.
共乘一片美好网络.

ASPJPEG水印使用简略说明吧(水印详细篇)

一、文字水印使用及对图片描边:

Set Jpeg = Server.CreateObject("Persits.Jpeg")
‘ 创建组件
Jpeg.Open Server.MapPath("images/dodge_viper.jpg")
‘ 打开图片
‘也可以用OpenBinary读取二进制数据
‘ 以下是写入水印文字
Jpeg.Canvas.Font.Color = &H000000 ‘ 颜色,这里是设置成:黑
Jpeg.Canvas.Font.Family = "宋体" ‘family设置字体
Jpeg.Canvas.Font.Bold = True  ‘是否设置成粗体
Jpeg.Canvas.Font.Size = 12 ‘字体大小
Jpeg.Canvas.Print 10, 10, "本论坛属拒绝游泳" ‘在相应的位置打印文字

‘下面是对图片进行描边处理
Jpeg.Canvas.Pen.Color = &H000000 ‘ 颜色
Jpeg.Canvas.Pen.Width = 2 ‘描边像素:单位pix
Jpeg.Canvas.Brush.Solid = False ‘ 如果要描边,这里不能设成"真",否则整个区域会被填充为上面的颜色
Jpeg.Canvas.Bar 1, 1, Jpeg.Width, Jpeg.Height ‘描边的位置及对应宽度

Jpeg.Save Server.MapPath("images/dodge_viper_framed.jpg") ‘OK,大功告成,输入保存!

一、文字水印使用及对图片描边:

Set Jpeg = Server.CreateObject("Persits.Jpeg")
‘ 创建组件
Jpeg.Open Server.MapPath("images/dodge_viper.jpg")
‘ 打开图片
‘也可以用OpenBinary读取二进制数据
‘ 以下是写入水印文字
Jpeg.Canvas.Font.Color = &H000000 ‘ 颜色,这里是设置成:黑
Jpeg.Canvas.Font.Family = "宋体" ‘family设置字体
Jpeg.Canvas.Font.Bold = True  ‘是否设置成粗体
Jpeg.Canvas.Font.Size = 12 ‘字体大小
Jpeg.Canvas.Print 10, 10, "本论坛属拒绝游泳" ‘在相应的位置打印文字

‘下面是对图片进行描边处理
Jpeg.Canvas.Pen.Color = &H000000 ‘ 颜色
Jpeg.Canvas.Pen.Width = 2 ‘描边像素:单位pix
Jpeg.Canvas.Brush.Solid = False ‘ 如果要描边,这里不能设成"真",否则整个区域会被填充为上面的颜色
Jpeg.Canvas.Bar 1, 1, Jpeg.Width, Jpeg.Height ‘描边的位置及对应宽度

Jpeg.Save Server.MapPath("images/dodge_viper_framed.jpg") ‘OK,大功告成,输入保存!
         

三、改变图片大小

Set Jpeg = Server.CreateObject("Persits.Jpeg")
Path = Server.MapPath("images") & "\clock.jpg"
Jpeg.Open Path

Jpeg.Width = Jpeg.OriginalWidth / 2
Jpeg.Height = Jpeg.OriginalHeight / 2
‘改变成原来的50%

Jpeg.Save Server.MapPath("images") & "\clock_small.jpg"

四..数据库操作

Set Upload = Server.CreateObject("Persits.Upload")
Count = Upload.Save("c:\upload")

If Count = 0 Then
Response.Write "No images selected."
Response.End
Else
Set File = Upload.Files(1)
If File.ImageType <> "UNKNOWN" Then ‘检测是否为识别文件

‘ 创建并打开文件
Set jpeg = Server.CreateObject("Persits.Jpeg")
jpeg.Open( File.Path )

‘ 按upload.form("scale")百份比改变图片大小
‘ 这里用upload.form,而不能用request.form
jpeg.Width = jpeg.OriginalWidth * Upload.Form("scale") / 100
jpeg.Height = jpeg.OriginalHeight * Upload.Form("scale") / 100

SavePath = "c:\upload\small_" & File.ExtractFileName

‘ aspJPG总是产生jpg格式文件,如果不是一个JPG文件,则添加扩展名.
If UCase(Right(SavePath, 3)) <> "JPG" Then
SavePath = SavePath & ".jpg"
End If

jpeg.Save SavePath ‘保存

‘写入数据库
Set conn = Server.CreateObject("ADODB.Connection")
connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("test.mdb")
conn.Open connstr
Set rs = Server.CreateObject("adodb.recordset")
rs.Open "select * from [images]", CONN, 1, 3
rs.AddNew
rs("original_image").Value = File.Binary
Set ThumbFile = Upload.OpenFile(SavePath)
rs("thumbnail").Value = ThumbFile.Binary
rs("description") = Upload.Form("Description")
rs.Update
rs.Close
Set rs = Nothing

Response.Write "Success! Both the original file and its thumbnail are saved in the database.<P>"
Response.Write "Copies can be found at <B>c:\upload\" & File.ExtractFileName & "</B> and <B>" & SavePath & "</B>"

Else
Response.Write "不可识别数据."
Response.End
End If
End If
‘结束

FONT对像的参数:

BkColor
BkMode
Bold
Color
Family
Italic
Quality
Rotation
ShadowColor
ShadowXoffset
ShadowYoffset
Size
Underlined

具体的参数说明:
http://www.aspjpeg.com/objectreference.html

下载:
[aspjpeg下载]http://www.chinaz.com/download/s/9226.asp
[aspupload下载]http://www.chinaz.com/download/s/9228.asp

name:www.chinaz.com
company:www.chinaz.com
sn:48958-77556-02411
 

赞(0)
未经允许不得转载:小叶白龙博客 » ASPJPEG水印使用简略说明吧(水印详细篇)
分享到: 更多 (0)

评论 抢沙发

评论前必须登录!