Friday, March 26, 2010

Drink Water After Listerine?

Resize Images imgs reduction magnification asp aruba

Upload and Resize images on the fly


This is an example to upload image and make a resize on the fly, reducing or enlarging the size of that image.


As usual we use the library provided by Persits, for both upload and resize.


The code is as follows:


 

\u0026lt;%
Sept. Upload = Server.CreateObject ("Persits.Upload.1)
'Upload.SetMaxSize 50000, True

path = Server.MapPath ( "/ public") On Error Resume Next


Upload.Save (path)


If Err.Number = 8 Then Response.Write "Your file is too large. Please try again."

Else If Err \u0026lt;> 0 Then
Response.Write "An error occurred:" & Err.Description

Else Response.Write "Success!"
End If
End If

Set File = Upload.Files("FILE2")
filename=File.FileName
'percorso = Server.URLEncode(Server.MapPath("/public/" & filename & ""))
'prova2 = Upload.Form("DESCR2")
'prova1= Upload.Form("DESCR1")

' AspJpeg
Set Jpeg = Server.CreateObject("Persits.Jpeg")

nomeimmaginerid = "thumb_"&filename
nomeimmagineing = "thumb2_"&filename

Path = percorso & "/" & filename

Jpeg.Open Path
Jpeg.Width = Jpeg.OriginalWidth /4
Jpeg.Height = Jpeg.OriginalHeight /4
Jpeg.Save (percorso & "/" & Nomeimmaginerid)

Jpeg.Open Path

Jpeg.Width = Jpeg.OriginalWidth
Jpeg.Height * 4 * 4 = Jpeg.OriginalHeight
Jpeg.Save (path & "/" & nomeimmagineing)


% >
\u0026lt;p> Original image \u0026lt;/ p>
\u0026lt;img src = "/ public / \u0026lt;% = filename%>" /> Image
\u0026lt;p> reduced \u0026lt;/ p>
\u0026lt;img src = "/ public / thumb_ \u0026lt;% = filename%>" />
\u0026lt;p> sized image \u0026lt;/ p>
\u0026lt;img src = "/ public/thumb2_ \u0026lt;% = filename%>" />




Qui trovate l'esempio funzionante: Upload Resize al volo di Immagini con ASP Persits su Aruba

0 comments:

Post a Comment