begin process at 2012 05 27 23:44:15
  Trouver un code source :
 
dans
 
Accueil > Forum > 

Archive ASP & ASP.NET

 > 

Archives ASP & ASP.NET

 > 

Chili!ASP

 > 

function gfxSpex > marche avec IIS mais pas avec Apache+Chilisoft


Derniers messages déposésPoser une question dans le forum ou lancer une discussion

function gfxSpex > marche avec IIS mais pas avec Apache+Chilisoft

lundi 24 juin 2002 à 17:30:02 | function gfxSpex > marche avec IIS mais pas avec Apache+Chilisoft

tristanaspfr

Bonjour,

j'utilise le code ci-dessous pour récupérer la taille d'une image sur le serveur. Cela marche très bien sur un serveur IIS, mais avec Apache+Chilisoft rien à faire... La page ne se charge pas et aucun message d'erreur (ça plante carrément le serveur !)

Quelqu'un voit où est le pb ?
Merci d'avance à celui (ou celle !) qui me sauvera la vie !!!!!!!!!!!

Cordialement, Tristan


les code :

<%
'::: This routine will attempt to identify any filespec passed :::
'::: as a graphic file (regardless of the extension). This will :::
'::: work with BMP, GIF, JPG and PNG files. :::

'::: Based on ideas presented by David Crowell :::

'strFlnm => Filespec of file to read
'lngWidth => width of image
'lngHeight => height of image '
'lngDepth => color depth (in number of colors)
'strImageType => type of image (e.g. GIF, BMP, etc.)
'The routine returns FALSE if the file was not recognized as a valid image type, and TRUE if it is 'probably' a valid image file.

'::: Copyright *c* MM, Mike Shaffer blah blah :::
':: ALL RIGHTS RESERVED WORLDWIDE blah blah :::
'::: Permission is granted to use this code blah blah :::
':: in your projects, as long as this blah blah :::
':: copyright notice is included blah blah :::

function GetBytes(flnm, offset, bytes)
Dim objFSO
Dim objFTemp
Dim objTextStream
Dim lngSize

on error resume next
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFTemp = objFSO.GetFile(flnm)
lngSize = objFTemp.Size
set objFTemp = nothing
fsoForReading = 1
Set objTextStream = objFSO.OpenTextFile(flnm, fsoForReading)

if offset > 0 then
strBuff = objTextStream.Read(offset - 1)
end if

if bytes = -1 then
GetBytes = objTextStream.Read(lngSize) 'ReadAll
else
GetBytes = objTextStream.Read(bytes)
end if

objTextStream.Close
set objTextStream = nothing
set objFSO = nothing
end function


function lngConvert(strTemp)
lngConvert = clng(asc(left(strTemp, 1)) + ((asc(right(strTemp, 1)) * 256)))
end function

function lngConvert2(strTemp)
lngConvert2 = clng(asc(right(strTemp, 1)) + ((asc(left(strTemp, 1)) * 256)))
end function

function gfxSpex(flnm, width, height, depth, strImageType)
dim strPNG
dim strGIF
dim strBMP
dim strType
strType = ""
strImageType = "(unknown)"
gfxSpex = False

strPNG = chr(137) & chr(80) & chr(78)
strGIF = "GIF"
strBMP = chr(66) & chr(77)
strType = GetBytes(flnm, 0, 3)

if strType = strGIF then
strImageType = "GIF"
Width = lngConvert(GetBytes(flnm, 7, 2))
Height = lngConvert(GetBytes(flnm, 9, 2))
Depth = 2 ^ ((asc(GetBytes(flnm, 11, 1)) and 7) + 1)
gfxSpex = True

elseif left(strType, 2) = strBMP then

strImageType = "BMP"
Width = lngConvert(GetBytes(flnm, 19, 2))
Height = lngConvert(GetBytes(flnm, 23, 2))
Depth = 2 ^ (asc(GetBytes(flnm, 29, 1)))
gfxSpex = True

elseif strType = strPNG then

strImageType = "PNG"
Width = lngConvert2(GetBytes(flnm, 19, 2))
Height = lngConvert2(GetBytes(flnm, 23, 2))
Depth = getBytes(flnm, 25, 2)

select case asc(right(Depth,1))
case 0
Depth = 2 ^ (asc(left(Depth, 1)))
gfxSpex = True
case 2
Depth = 2 ^ (asc(left(Depth, 1)) * 3)
gfxSpex = True
case 3
Depth = 2 ^ (asc(left(Depth, 1))) '8
gfxSpex = True
case 4
Depth = 2 ^ (asc(left(Depth, 1)) * 2)
gfxSpex = True
case 6
Depth = 2 ^ (asc(left(Depth, 1)) * 4)
gfxSpex = True
case else
Depth = -1
end select


else

strBuff = GetBytes(flnm, 0, -1)
lngSize = len(strBuff)
flgFound = 0

strTarget = chr(255) & chr(216) & chr(255)
flgFound = instr(strBuff, strTarget)

if flgFound = 0 then
exit function
end if

strImageType = "JPG"
lngPos = flgFound + 2
ExitLoop = false

do while ExitLoop = False and lngPos < lngSize

do while asc(mid(strBuff, lngPos, 1)) = 255 and lngPos < lngSize
lngPos = lngPos + 1
loop

if asc(mid(strBuff, lngPos, 1)) < 192 or asc(mid(strBuff, lngPos, 1)) > 195 then
lngMarkerSize = lngConvert2(mid(strBuff, lngPos + 1, 2))
lngPos = lngPos + lngMarkerSize + 1
else
ExitLoop = True
end if

loop
'
if ExitLoop = False then

Width = -1
Height = -1
Depth = -1

else
Height = lngConvert2(mid(strBuff, lngPos + 4, 2))
Width = lngConvert2(mid(strBuff, lngPos + 6, 2))
Depth = 2 ^ (asc(mid(strBuff, lngPos + 8, 1)) * 8)
gfxSpex = True
end if
end if
end function
%>


Cette discussion est classée dans : asc, depth, getbytes, flnm, gfxspex


Répondre à ce message

Sujets en rapport avec ce message

fonctions mid(), asc() et chr() ? [ par frogman ] J'aimerais savoir précisemment à quoi servent et comment fonctionnent ces trois fonctions :mid()asc()chr()Y'a-t-il un site explicatif regroupant toute ASC [ par zbe ] SELECT domaines.id_domaines, domaines.domaines, t_cours.domaines, t_cours.id_cours, t_cours.code_cours, t_cours.libelle_cours, t_cours.dure, t_cours.t un problème en ASP.NET [ par jarmoud ] Bonjour, J'ai un textbox btntext.Text = "ASC" et un bouton dont l'action est la suivante: [code=vb] Protected Sub Button1_Click(ByVal sender As


Nos sponsors


Sondage...

Comparez les prix

CalendriCode

Mai 2012
LMMJVSD
 123456
78910111213
14151617181920
21222324252627
28293031   

Consulter la suite du CalendriCode

A découvrir



 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 0,343 sec (4)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales