Voici maintenant la procedure redimImage traduite en ASP- VBScript pour redimensionner les images a la volee :
Sub redimImage :
Sub redimImage(inImg, inW, inH, inMW, inMH) ' Cette function recoit 5 parametres ' inImg : Chemin relatif de l'image ' inW : Largeur de l'image ' inH : Hauteur de l'image ' inMW : Largeur maximale ' inMH : Hauteur maximale maxWidth = CInt(inMW) maxHeight = CInt(inMH) ' Declarations des variables "Nouvelle Taille" dW = 0 dH = 0 ' On recupere les tailles reelles h = CInt(inH) : w = CInt(inW) dH = CInt(inH) : dW = CInt(inW) ' Si la largeur ou la hauteur depasse la taille maximale If h >= maxHeight Or w >= maxWidth Then ' Si la largeur et la hauteur depasse la taille maximale If h >= maxHeight And w >= maxWidth Then ' On cherche la plus grande valeur If h > w Then dH = maxHeight ' On recalcule la taille proportionnellement dW = CInt((w * dH) / h) Else dW = maxWidth ' On recalcule la taille proportionnellement dH = CInt((h * dW) / w) End If ElseIf h > maxHeight And w < maxWidth Then ' Si la hauteur depasse la taille maximale dH = maxHeight ' On recalcule la taille proportionnellement dW = CInt((w * dH) / h) ElseIf h < maxHeight And w > maxWidth Then ' Si la largeur depasse la taille maximale dW = maxWidth ' On recalcule la taille proportionnellement dH = CInt((h * dW) / w) End If End If ' On ecrit l'image dans le document Response.Write "<img src=""" & inImg & """ width=""" & dW & """ height=""" & dH & """ border=""0"">" End Sub