Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > pure asp way to get image width and height

Reply
Thread Tools

pure asp way to get image width and height

 
 
Nancy Drew
Guest
Posts: n/a
 
      10-28-2004
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


 
Reply With Quote
 
 
 
 
Maarten
Guest
Posts: n/a
 
      10-28-2004
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


 
Reply With Quote
 
 
 
 
Aaron [SQL Server MVP]
Guest
Posts: n/a
 
      10-28-2004
http://www.aspfaq.com/2170

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




"Nancy Drew" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
 
Evertjan.
Guest
Posts: n/a
 
      10-28-2004
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)

 
Reply With Quote
 
Maarten
Guest
Posts: n/a
 
      10-29-2004

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




"Aaron [SQL Server MVP]" <(E-Mail Removed)> schreef in bericht
news:%23ifC%(E-Mail Removed)...
> http://www.aspfaq.com/2170
>
> --
> http://www.aspfaq.com/
> (Reverse address to reply.)
>
>
>
>
> "Nancy Drew" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> 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
>>
>>

>
>



 
Reply With Quote
 
Aaron [SQL Server MVP]
Guest
Posts: n/a
 
      10-29-2004
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" <(E-Mail Removed)> wrote in message
news:eMkgd.3209$(E-Mail Removed)-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]" <(E-Mail Removed)> schreef in bericht
> news:%23ifC%(E-Mail Removed)...
> > http://www.aspfaq.com/2170
> >
> > --
> > http://www.aspfaq.com/
> > (Reverse address to reply.)
> >
> >
> >
> >
> > "Nancy Drew" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> >> 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
> >>
> >>

> >
> >

>
>



 
Reply With Quote
 
Nancy Drew
Guest
Posts: n/a
 
      10-29-2004
excellent - the code works great. thannks maarten.



"Maarten" <(E-Mail Removed)> wrote in message
news:chcgd.2953$(E-Mail Removed)-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
>
>



 
Reply With Quote
 
trebitzki@gmx.net
Guest
Posts: n/a
 
      11-09-2004
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...
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Why can't I change height with <col width="50" height="100">? Bernd Meier HTML 6 01-14-2008 07:25 AM
CSS min-width, max-width, and min-height with display:inline Lois HTML 1 12-27-2004 03:03 AM
How to get the width and height of a image by its given URL? =?Utf-8?B?TGFzZXIgTHU=?= ASP .Net 1 06-01-2004 01:56 PM
Easy way to tell height and width of an image? Robert Mark Bram Javascript 7 07-15-2003 04:31 PM
Easy way to tell height and width of an image? Robert Mark Bram HTML 13 07-15-2003 04:31 PM



Advertisments