473,238 Members | 1,787 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,238 software developers and data experts.

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 18572
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: ok | last post by:
Hello, Q: How do I get image width and height before uploading an image? This because, I want to restrict people uploading huge files. Thanks in advance
7
by: Premshree Pillai | last post by:
Hello, Is there a Py module available using which I can find the width and height of any image format? -Premshree ===== -Premshree http://www.qiksearch.com/]
5
by: homecurr | last post by:
I am writing a tool to generate html and have a problem with the <img> tag. The tool generates something like "<img src="...">". At the time the html is generated, the tool does not know the actual...
2
by: Dave | last post by:
Dear Sirs, Is there a way to get the width and height of an image without downloading the image, or with just downloading a minimal portion of the image? For instance, I have a list of 10,000...
10
by: News | last post by:
I am trying to be able to manipulate the width and height of an <img> but do not seem to be able. "Yes", I know the JavaScript will "not" manip anything, which is ok. I simply do not know how to...
1
by: emilmgeorge | last post by:
Pls somebody give me the code for getting the height and width of a image in pixels in javascript or asp. Thanks - Emil
2
by: Atul | last post by:
I am unable to find image height and width in mozilla firefox. My code is working in IE but not in Mozilla. How can i find image width and height in mozilla? function check(sel) { if(sel != "")...
1
epots9
by: epots9 | last post by:
I have a image inside of a div <div id="image"> <div id="loader"> <img id="loaderImage" src="assets/loader.gif" alt="loading..." /> </div> <div id="loaded"> <img id="picture" src="" alt=""...
5
Mike Kypriotis
by: Mike Kypriotis | last post by:
in php with getimagesize() for both img and swf worked well,in javascript? PS I do not want to first load it and then use its id as a reference object, I want to know because I need to know in...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.