Sitter med aspjpeg kod till mitt fotoalbum.
Scriptet är taget på aspjpeg.com och funkar bara bra att ladda upp bilder och göra en thumbnail bild till den. Men jags kulle vilja ha det så att den även skriver en text på bilden...
Har lagt in denna koden:
Jpeg.Canvas.Font.Color = &HFF0000 ' Red
Jpeg.Canvas.Font.Family = "Verdana"
Jpeg.Canvas.Font.Bold = True
Jpeg.Canvas.Font.Quality = 4 ' Antialiased
Jpeg.Canvas.Font.BkMode = "Opaque" ' to make antialiasing work
Jpeg.Canvas.Print 10, 572, "Copyright (c) Fam sköld."
' Draw frame: black, 2-pixel width
Jpeg.Canvas.Pen.Color = &H000000 ' Black
Jpeg.Canvas.Pen.Width = 2
Jpeg.Canvas.Brush.Solid = False ' or a solid bar would be drawn
Jpeg.Canvas.DrawBar 1, 1, Jpeg.Width, Jpeg.Height
Men det vill inte fungera...!
Har jag lagt den fel eller??
Här är hela koden:
<%
' Create an instance of AspUpload object
Set Upload = Server.CreateObject("Persits.Upload")
' Compute path to save uploaded files to
Path = Server.MapPath("/blog/test/foto/")
' Capture uploaded file. Return the number of files uploaded
Count = Upload.Save(Path)
If Count = 0 Then
Response.Write "No images selected."
Response.End
Else
' Obtain File object representing uploaded file
Set File = Upload.Files(1)
' Is this a valid image file?
If File.ImageType <> "UNKNOWN" Then
' Create instance of AspJpeg object
Set jpeg = Server.CreateObject("Persits.Jpeg")
' Open uploaded file
jpeg.Open( File.Path )
' Draw text
Jpeg.Canvas.Font.Color = &HFF0000 ' Red
Jpeg.Canvas.Font.Family = "Verdana"
Jpeg.Canvas.Font.Bold = True
Jpeg.Canvas.Font.Quality = 4 ' Antialiased
Jpeg.Canvas.Font.BkMode = "Opaque" ' to make antialiasing work
Jpeg.Canvas.Print 10, 572, "Copyright (c) Fam sköld."
' Draw frame: black, 2-pixel width
Jpeg.Canvas.Pen.Color = &H000000 ' Black
Jpeg.Canvas.Pen.Width = 2
Jpeg.Canvas.Brush.Solid = False ' or a solid bar would be drawn
Jpeg.Canvas.DrawBar 1, 1, Jpeg.Width, Jpeg.Height
' Resize image
Jpeg.PreserveAspectRatio = True
'Minska bilden med maxbredd 50px
Jpeg.Width = 70
SavePath = Path & "\small_" & File.ExtractFileName
' AspJpeg always generates thumbnails in JPEG format.
' If the original file was not a JPEG, append .JPG ext.
If UCase(Right(SavePath, 3)) <> "JPG" Then
SavePath = SavePath & ".jpg"
End If
jpeg.Save SavePath
' Save both images in the database along with description.
strConnect = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("test.mdb")
Set rs = Server.CreateObject("adodb.recordset")
rs.Open "images", strConnect, 1, 3
rs.AddNew
' Use File.Binary to access binary data of uploaded file.
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!"
Else
Response.Write "This is not a valid image."
Response.End
End If
End If
%>
Och en sak till...när jag laddar upp bilden så verkar kvaliteten på bilden försämras...kan man ställa in dte på något vis??
Mvh Martin!