469,288 Members | 2,353 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,288 developers. It's quick & easy.

pure asp way to get image width and height

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
Jul 21 '05 #1
7 18141
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
Jul 21 '05 #2
http://www.aspfaq.com/2170

--
http://www.aspfaq.com/
(Reverse address to reply.)


"Nancy Drew" <ge*****@hotmail.com> wrote in message
news:dI********************@rogers.com...
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

Jul 21 '05 #3
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.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress,
but let us keep the discussions in the newsgroup)

Jul 21 '05 #4

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


"Aaron [SQL Server MVP]" <te*****@dnartreb.noraa> schreef in bericht
news:%2*****************@TK2MSFTNGP11.phx.gbl...
http://www.aspfaq.com/2170

--
http://www.aspfaq.com/
(Reverse address to reply.)


"Nancy Drew" <ge*****@hotmail.com> wrote in message
news:dI********************@rogers.com...
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


Jul 21 '05 #5
I was recommending the script portion of the article, since the OP asked for
a component-less solution.

--
http://www.aspfaq.com/
(Reverse address to reply.)


"Maarten" <pl****@no-mail.com> wrote in message
news:eM*******************@phobos.telenet-ops.be...

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


"Aaron [SQL Server MVP]" <te*****@dnartreb.noraa> schreef in bericht
news:%2*****************@TK2MSFTNGP11.phx.gbl...
http://www.aspfaq.com/2170

--
http://www.aspfaq.com/
(Reverse address to reply.)


"Nancy Drew" <ge*****@hotmail.com> wrote in message
news:dI********************@rogers.com...
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



Jul 21 '05 #6
excellent - the code works great. thannks maarten.

"Maarten" <pl****@no-mail.com> wrote in message
news:ch*******************@phobos.telenet-ops.be...
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

Jul 21 '05 #7
Here is the url to the pure asp solution:

http://www.4guysfromrolla.com/webtech/050300-1.shtml

Just scroll down to the download link and include the file in your project!

Have fun!

Timm

************************************************** ********************
Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources...
Jul 21 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by ok | last post: by
7 posts views Thread by Premshree Pillai | last post: by
5 posts views Thread by homecurr | last post: by
10 posts views Thread by News | last post: by
2 posts views Thread by Atul | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.