ASP - Como detectar width y height

 
Vista:

Como detectar width y height

Publicado por Jorge (2 intervenciones) el 02/08/2006 19:32:34
Necesito saber si exite alguna forma de conocer el width y height de una imagen cuando las subo al hostig via upload o con alguna instruccion asp. esto lo necesito para hacer unos calculos con los pixeles...

ayudenme porfavoor!.+
gracias
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de Santos Pairazamán

RE:Como detectar width y height

Publicado por Santos Pairazamán (15 intervenciones) el 04/08/2006 19:48:55
En visual Basic utlizo esta función dentro de un módulo

Public Type BITMAPINFO
Width As Long
Height As Long
End Type

Public Function GetJPGInfo(ByVal FileName As String) As BITMAPINFO
Dim bChar As Byte
Dim a As Byte, b As Byte
Dim c As Byte, D As Byte
Dim E As Byte, f As Byte
Dim i As Integer
Dim DotPos As Integer
Dim Header As String
Dim blExit As Boolean
Dim MarkerLen As Long
Dim ImgWidth As Integer
Dim ImgHeight As Integer
Dim ImgSize As String
Dim fnum As Integer
Dim ImageInfo As BITMAPINFO
On Error Resume Next

fnum = FreeFile
Open FileName For Binary As #fnum

ImgSize = LOF(fnum) / 1024
DotPos = InStr(ImgSize, ",")
ImgSize = Left(ImgSize, DotPos)

Get #fnum, , bChar
Header = Hex$(bChar)
Get #fnum, , bChar
Header = Header & Hex$(bChar)
If Header <> "FFD8" Then Exit Function

While Not blExit
Do Until Hex$(bChar) = "FF"
Get #fnum, , bChar
Loop

Get #fnum, , bChar
If Hex$(bChar) >= "C0" And _
Hex$(bChar) <= "C3" Then
Get #fnum, , bChar
Get #fnum, , bChar
Get #fnum, , bChar

Get #fnum, , bChar
a = bChar
Get #fnum, , bChar
b = bChar
Get #fnum, , bChar
c = bChar
Get #fnum, , bChar
D = bChar

ImgHeight = CInt(a * 256 + b)
ImgWidth = CInt(c * 256 + D)
blExit = True
Else
If Hex$(bChar) = "DA" Then
blExit = True
Else
Get #fnum, , bChar
E = bChar
Get #fnum, , bChar
f = bChar
MarkerLen = (E * 256 + f) - 2

Dim marker As String
marker = String(MarkerLen, vbNullChar)
Get #fnum, , marker
End If
End If
Wend

Close #fnum

With ImageInfo
.Width = ImgWidth
.Height = ImgHeight
End With

GetJPGInfo = ImageInfo
End Function
*********************

La llamo asi

Dim ImageInfo As BITMAPINFO
ImageInfo = GetJPGInfo("C:\WINDOWS\Escritorio\cua_buscador.jpg")
MsgBox ImageInfo.Height & " " & ImageInfo.Width

Espero t sirva
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar