Tips&Tricks I trucchi del mestiere

 

Creare delle immagini formato thumbnail

In un sito Web Φ sempre preferibile utilizzare delle immagini di formato ridotto che al semplice click del mouse possano mostrarsi nella loro interezza. Il tip mostra come realizzare delle immagini di formato ridotto note come thumbnail.

<%
Const MINPIXELS = 100

Set objImageSize = Server.CreateObject("ImgSize.Check")
objImageSize.FileName = Server.MapPath("IMG.jpg")
ImageHeight = objImageSize.Height
ImageWidth = objImageSize.Width
If ImageHeight > ImageWidth Then
    NewHeight = Cint(ImageHeight*MINPIXELS/ImageWidth)
    NewWidth = MINPIXELS
Else
    NewWidth = Cint(ImageWidth*MINPIXELS/ImageHeight)
    NewHeight = MINPIXELS
End If
Set objImageSize = Nothing

'*** Creazione dell'immagine thumbnail
Set Image = Server.CreateObject("AspImage.Image")
Image.LoadImage(Server.MapPath("IMG.jpg"))
Image.FileName = Server.MapPath("IMG_piccola.jpg")
Image.ImageFormat = 1
Image.JPEGQuality = 70
Image.Resize NewWidth,NewHeight
Image.SaveImage
Set Image = Nothing
%>



Creare un documento Word da ASP


Ecco come in modo semplice e veloce Φ possibile creare un documento Word da una comune pagina ASP. La pagina richiede di immettere dei semplici dati e da questi ne propone una visualizzazione in Word.

<form action="word_create.asp">
Name: <input type="text" name="Nome" size="50" maxlength="100">
Email: <input type="text" name="Email" size="50" maxlength="100">
Commenti:
<textarea cols="50" rows="10" name="commenti"></textarea> 
<input type="submit" value="Submit">
</form>

Di seguito come creare, di fatto, il documento Microsoft Word.

<% Response.ContentType = "application/msword" %>
<html>
<% strNome = Request.Querystring("Nome")
strEmail = Request.Querystring("Email")
strCommenti = Request.Querystring("Commenti")
%> 
<head>
</head>
<body>
<p align="right"><%=formatdatetime(now,2)%></p> 
Dear <%= strnome %>:
Il mio indirizzo email Φ: <%= stremail %>
Ecco qui i commenti: <%= strCommenti %>
</body>
</html>