473,508 Members | 2,428 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 18607
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
17464
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
4044
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
12283
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
7017
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
3259
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
1813
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
13404
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
4175
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
4183
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...
0
7133
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
7066
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7504
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5643
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5059
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3214
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3198
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1568
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
435
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.