Solved

image width, height and size

Posted on 2002-07-02
3
321 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 52

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
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…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

695 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