AspJPEG 物件 # 範例 # 浮水印 + 縮圖
說明:建立浮水印,並另存一張縮圖
<Form>
<FORM METHOD=POST ACTION="f1.asp" enctype="multipart/form-data">
<input name="file1" type="file" id="file1" size="20"><br>
<INPUT TYPE="submit" Name="s1" value="送出">
</FORM>
<input name="file1" type="file" id="file1" size="20"><br>
<INPUT TYPE="submit" Name="s1" value="送出">
</FORM>
<ASP>
<%
On Error Resume Next
Set objUpload = Server.CreateObject("Persits.Upload")
objUpload.SetMaxSize 300000, True '上傳檔案大小
Count = objUpload.Save 'File Save to Memory
If Err.Number <> 0 Then
Response.Write "發生錯誤:" & "<br>"
Response.Write "ErrCode = " & Err.Number & "<br>"
Response.Write "ErrMsg = "& Err.Description & "<br><br>"
Set objUpload = Nothing
Response.End
End if
On Error Goto 0
imagefullpath = "."
FileBody = ""
'Step 1) 檢查上傳的檔案格式是否為jpg 或是 gif
'###################################
Set File = objUpload.Files("file1")
IF Not File Is Nothing Then
If File.ImageType <> "UNKNOWN" Then
CALL ImageAddWord(Server.Mappath(imagefullpath & "/1_1" & File.Ext), File.Binary, "大")
CALL ImageAddWord(Server.Mappath(imagefullpath&"/S1_1" & File.Ext),File.Binary,"小")
Else
Response.Write "發生錯誤:" & "<br>"
Response.Write "上載的不是圖檔格式==>" & File.ImageType & "<br>"
Set objUpload = Nothing
Response.End
End if
End if
Set File = Nothing
Set objUpload = Nothing
Response.Write("上載完成")
On Error Resume Next
Set objUpload = Server.CreateObject("Persits.Upload")
objUpload.SetMaxSize 300000, True '上傳檔案大小
Count = objUpload.Save 'File Save to Memory
If Err.Number <> 0 Then
Response.Write "發生錯誤:" & "<br>"
Response.Write "ErrCode = " & Err.Number & "<br>"
Response.Write "ErrMsg = "& Err.Description & "<br><br>"
Set objUpload = Nothing
Response.End
End if
On Error Goto 0
imagefullpath = "."
FileBody = ""
'Step 1) 檢查上傳的檔案格式是否為jpg 或是 gif
'###################################
Set File = objUpload.Files("file1")
IF Not File Is Nothing Then
If File.ImageType <> "UNKNOWN" Then
CALL ImageAddWord(Server.Mappath(imagefullpath & "/1_1" & File.Ext), File.Binary, "大")
CALL ImageAddWord(Server.Mappath(imagefullpath&"/S1_1" & File.Ext),File.Binary,"小")
Else
Response.Write "發生錯誤:" & "<br>"
Response.Write "上載的不是圖檔格式==>" & File.ImageType & "<br>"
Set objUpload = Nothing
Response.End
End if
End if
Set File = Nothing
Set objUpload = Nothing
Response.Write("上載完成")
Sub ImageAddWord(fileName,imgBlg,size)
Set Jpeg = Server.CreateObject("Persits.Jpeg")
Jpeg.OpenBinary imgBlg
' Draw text
Jpeg.Canvas.Font.Color = &HFF0000 ' Red
Jpeg.Canvas.Font.Family = "Courier New"
Jpeg.Canvas.Font.Bold = True
Jpeg.Canvas.Font.Quality = 4 ' Antialiased
Jpeg.Canvas.Font.BkMode = "Opaque" ' to make antialiasing work
Jpeg.Canvas.Print 10, Jpeg.Height - 30, "Copyright Yippee."
If size = "小" Then
Jpeg.Width = Jpeg.Width / 2
Jpeg.Height = Jpeg.Height / 2
end if
Jpeg.Save fileName
Set Jpeg = Nothing
End Sub
%>
Set Jpeg = Server.CreateObject("Persits.Jpeg")
Jpeg.OpenBinary imgBlg
' Draw text
Jpeg.Canvas.Font.Color = &HFF0000 ' Red
Jpeg.Canvas.Font.Family = "Courier New"
Jpeg.Canvas.Font.Bold = True
Jpeg.Canvas.Font.Quality = 4 ' Antialiased
Jpeg.Canvas.Font.BkMode = "Opaque" ' to make antialiasing work
Jpeg.Canvas.Print 10, Jpeg.Height - 30, "Copyright Yippee."
If size = "小" Then
Jpeg.Width = Jpeg.Width / 2
Jpeg.Height = Jpeg.Height / 2
end if
Jpeg.Save fileName
Set Jpeg = Nothing
End Sub
%>
sourceURL : http://www.blueshop.com.tw/board/show.asp?subcde=BRD200502021637177QM&fumcde=