0/5 (4 avis)
Snippet vu 12 446 fois - Téléchargée 38 fois
Function GetPicSize (fn) Set fso = CreateObject("Scripting.FileSystemObject") if fso.FileExists(Server.MapPath(fn)) = false then exit function pn = Server.MapPath(fn) tstr = "" Set f = fso.OpenTextFile(pn) Select Case UCase(Right(fn,4)) Case ".GIF",".JPG" If NOT f.AtEndOfStream Then If UCase(Right(fn,4))=".GIF" Then chars = f.read(10) width = asc(mid(chars,8,1))*256 + asc(mid(chars,7,1)) height = asc(mid(chars,10,1))*256 + asc(mid(chars,9,1)) hw = " WIDTH=" & width & " HEIGHT=" & height Else chars = f.read(200) height = asc(mid(chars,164,1))*256 + asc(mid(chars,165,1)) width = asc(mid(chars,166,1))*256 + asc(mid(chars,167,1)) If (height>600) OR (height<3) OR (WIDTH<3) OR (WIDTH>600) Then Else hw = " WIDTH=" & width & " HEIGHT=" & height End If End If End If GetPicSize = "W : " & width & " H :" & height End Select f.Close Set f = Nothing Set fso = Nothing End Function
8 août 2003 à 16:31
8 août 2003 à 11:32
A+
8 août 2003 à 11:31
-----------------------------------------------------------------------
Sub GetJpegDims(ByVal strFileName, ByRef lngHeight, ByRef lngWidth)
on error resume next
Dim stmFile
set stmFile = server.createobject("ADODB.Stream")
Dim bytArr(256)
dim byt
Dim intPos
With stmFile
.Type = adTypeBinary
.Open
.LoadFromFile strFileName
.Position = 0
for intPos = 0 to 255
.position = intpos
bytArr(intPos) = ascb(.Read(1))
next
.Close
End With
Set stmFile = Nothing
For intPos = 0 To 255
If bytArr(intPos) = &HFF And bytArr(intPos + 1) >= &HC0 _
And bytArr(intPos + 1) <= &HCF Then
lngHeight = bytArr(intPos + 5) * 256 + bytArr(intPos + 6)
lngWidth = bytArr(intPos + 7) * 256 + bytArr(intPos + 8)
Exit For
End If
Next
End Sub
1 févr. 2002 à 15:42
Vous n'êtes pas encore membre ?
inscrivez-vous, c'est gratuit et ça prend moins d'une minute !
Les membres obtiennent plus de réponses que les utilisateurs anonymes.
Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.
Le fait d'être membre vous permet d'avoir des options supplémentaires.