Solved

image width, height and size

Posted on 2002-07-02
3
314 Views
Last Modified: 2006-11-17
Hi,

How to check the images widht, height and size in asp code?

Please help.

Thanks.
0
Comment
Question by:ht055
3 Comments
 
LVL 49

Accepted Solution

by:
Ryan Chong earned 30 total points
ID: 7124057
0
 
LVL 2

Expert Comment

by:zombeen
ID: 7124296
ASPImage is anotyher very good component , used for this + a lot of other things
u shd get that one too from www.serverobjects.com
0
 
LVL 9

Expert Comment

by:AlfaNoMore
ID: 7126424
OR...

Sub getJPEGDimensions(ByVal filename, ByRef width, ByRef height)
     '// sets width and height to the values scooped from the JPEG referenced by filename
     '// Assumes filename supplies a full path (i.e. it has been MapPath'ed)

     Dim lBinPrefix
     Dim lLngStart
     Dim binaryData, objFS, objFile
     
     'filename = Server.MapPath(filename)
     Set objFS = Server.CreateObject("Scripting.FileSystemObject")
     
     Set objFile = objFS.OpenTextFile(filename)
     If Not objFile.AtEndOfStream Then
          binaryData = ChrB(Asc(objFile.Read(1)))
          While Not objFile.AtEndOfStream
                binaryData = binaryData & ChrB(Asc(objFile.Read(1)))
          Wend
     End If
     objFile.Close
     Set objFile = Nothing
     Set objFS = Nothing
     
     
     ' Prefix found before image dimensions          
     lBinPrefix = ChrB(&h00) & ChrB(&h11) & ChrB(&h08)
     
     ' Find the last prefix (so we don't confuse it with data)          
     lLngStart = 1
     Do
          If InStrB(lLngStart, binaryData, lBinPrefix) + 3 = 3 Then Exit Do
          lLngStart = InStrB(lLngStart, binaryData, lBinPrefix) + 3
     Loop
     ' If a prefix was found
     If Not lLngStart = 1 Then
          width = CLng("&h" & HexAt(lLngStart+2, binaryData) & HexAt(lLngStart+3, binaryData))
          height = CLng("&h" & HexAt(lLngStart, binaryData) & HexAt(lLngStart+1, binaryData))
     End If
End Sub


Function HexAt(ByRef pLngPosition, ByRef mStrBinaryData)
     If pLngPosition > LenB(mStrBinaryData) Or pLngPosition <= 0 Then Exit Function
     HexAt = Right("0" & Hex(AscB(MidB(mStrBinaryData, pLngPosition, 1))), 2)
End Function

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now