Page 1 of 1
Gestion des erreurs ASP [French]
Posted: Fri Jan 28, 2005 8:31 am
by Yann
Bonjour
Je voudrais pouvoir gérer les erreur d'affichage selon si le format d'une image est reconnu ou pas
j'ai fait ceci mais ca ne marche pas
Code: Select all
on error resume next
File = request.querystring("fichier")
const AX_JPEG = 3
const AX_To16Colors = 16
With ctrl
.EnableLZW = TRUE
.LoadBitmap File
if error<>"" then
response.redirect "erreur.asp?id="&File
end if
' .ChangeColorDepth AX_To16Colors
.FontName = "arial"
.FontSize = 13
.TextOut .About, 2, 2, RGB(255, 255, 255) 'Write library version on the picture
.Saveformat = AX_JPEG
response.contenttype = "image/jpeg"
response.binarywrite .SendBinary
end with
Merci
Yann
Re: Gestion des erreurs ASP [FRENCH]
Posted: Fri Jan 28, 2005 9:05 am
by helmut
Yann wrote:Bonjour
Je voudrais pouvoir gérer les erreur d'affichage selon si le format d'une image est reconnu ou pas
j'ai fait ceci mais ca ne marche pas
Code: Select all
on error resume next
File = request.querystring("fichier")
const AX_JPEG = 3
const AX_To16Colors = 16
With ctrl
.EnableLZW = TRUE
.LoadBitmap File
if error<>"" then
response.redirect "erreur.asp?id="&File
end if
' .ChangeColorDepth AX_To16Colors
.FontName = "arial"
.FontSize = 13
.TextOut .About, 2, 2, RGB(255, 255, 255) 'Write library version on the picture
.Saveformat = AX_JPEG
response.contenttype = "image/jpeg"
response.binarywrite .SendBinary
end with
Merci
Yann
Dans les examples, le response du fonction est utilise comme image:
Peut-être c'est le probleme.
Aussi, j'essayerai cela:
Code: Select all
if error<>"" then
response.redirect "erreur.asp?id="&File
Exit ' ???
end if
Je pense qu'il te faut changer l'example completement, mais je ne sais pas comment. Une autre possiblities est un image avec la message, mais ce n'est pas très bon est pas flexible.
La solution
Posted: Fri Jan 28, 2005 10:01 am
by Yann
Bon j'ai trouvé voilà ce que j'ai fait si ca peut vous servir...
- image.asp
Code: Select all
Dim Path, File
Set ctrl = server.createobject("GflAx.GflAx")
File = request.querystring("fichier")
on error resume next
const AX_JPEG = 3
const AX_To16Colors = 16
With ctrl
.EnableLZW = TRUE
.LoadBitmap File
if err.description=>"Unknown format" then
response.redirect "erreur.asp?Fichier="&File
end if
.ChangeColorDepth AX_To16Colors
'.EnableLZW
newWidth = 120 'Get the height according to the width (keep the ratio)
newHeight = (newWidth * .Height) / .Width
.Resize newWidth, newHeight 'Resize the pciture
.FontName = "arial"
.FontSize = 13
.TextOut .About, 2, 2, RGB(255, 255, 255) 'Write library version on the picture
.Saveformat = AX_JPEG
response.contenttype = "image/jpeg"
response.binarywrite .SendBinary
end with
set ctrl=nothing
- erreur.asp
Code: Select all
Set FSO = Server.CreateObject("Scripting.FileSystemObject")
chemin=request.querystring("fichier")
image="D:\users\chrominteractiv\ci.chrom.fr\htdocs\OpenVisio\Pictos\pictos\"&FSO.GetExtensionName(chemin)&".jpg"
If not FSO.FileExists(image) Then
icone="D:\Pictos\pictos\inconnu.gif"
else
icone="D:\users\Pictos\pictos\"&FSO.GetExtensionName(chemin)&".jpg"
end if
set Fichier=nothing
Set ctrl = server.createobject("GflAx.GflAx")
File = icone
const AX_JPEG = 3
const AX_To16Colors = 16
With ctrl
.EnableLZW = TRUE
.LoadBitmap File
.FontName = "arial"
.FontSize = 13
.TextOut .About, 2, 2, RGB(255, 255, 255) 'Write library version on the picture
.Saveformat = AX_JPEG
response.contenttype = "image/jpeg"
response.binarywrite .SendBinary
end with
set ctrl=nothing
Ds mon repertoire picto il ya des image du type mov.jpg, ai.jpg etc qui reprenne en fait l'extension_du_fichier_non_reconnu.jpg
S'il trouve l'icone associée à l'extension il l'affiche sinon il affiche inconnu.jpg
ca marche

))
Yann
Re: La solution
Posted: Fri Jan 28, 2005 10:16 am
by helmut
Yann wrote:ca marche

))
Yann
Bon et merci de placer ta solution ice. Il me semble que ton code et solution est encore en stade 'experimentuel':
Code: Select all
if err.description=>"Unknown format" then
Je pense que ca serait dire:
Mais je ne veut pas commencer une discussion sur le style du code ici...