pure asp way to get image width and height

N

Nancy Drew

does anybody know of a way to get an image width and height without using a
custom dll? we have aspJPEG on the server, and there are methods to fetch
image width and height with that, but it only works with JPEG and i need to
get dimensions for gif and png, too.

tks
 
M

Maarten

sub ImgDimension(img)
dim myImg, fs
Set fs= CreateObject("Scripting.FileSystemObject")
if not fs.fileExists(img) then exit sub
set myImg = loadpicture(img)
iWidth = round(myImg.width / 26.4583)
iHeight = round(myImg.height / 26.4583)
iType = myImg.Type
select case iType
case 0
iType = "None"
case 1
iType = "Bitmap"
case 2
iType = "Metafile"
case 3
iType = "Icon"
case 4
iType = "Win32-enhanced metafile"
end select
set myImg = nothing
end sub
 
E

Evertjan.

Nancy Drew wrote on 28 okt 2004 in
microsoft.public.inetserver.asp.general:
does anybody know of a way to get an image width and height without
using a custom dll? we have aspJPEG on the server, and there are
methods to fetch image width and height with that, but it only works
with JPEG and i need to get dimensions for gif and png, too.

A gif file starts with 6 bytes of header containing something like

Hex 47-49-46-38-39-61

this is the string: "GIF89a"

Then follow 4 bytes [nr 7 to 10], say 17-04-ec-02

Hex 0417 = decimal 1047 pixels width
Hex 02ec = decimal 748 pixels height

reading the file serverside in a byte stream
and parsing these first 10 bytes must give you the picture size.
 
M

Maarten

imgsize.dll is not 100%. We started a project and unfortunaly we must
replace the dll by the script.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top