pure asp way to get image width and height

Discussion in 'ASP General' started by Nancy Drew, Oct 28, 2004.

  1. Nancy Drew

    Nancy Drew Guest

    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
     
    Nancy Drew, Oct 28, 2004
    #1
    1. Advertising

  2. Nancy Drew

    Maarten Guest

    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
     
    Maarten, Oct 28, 2004
    #2
    1. Advertising

  3. http://www.aspfaq.com/2170

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




    "Nancy Drew" <> wrote in message
    news:...
    > 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
    >
    >
     
    Aaron [SQL Server MVP], Oct 28, 2004
    #3
  4. Nancy Drew

    Evertjan. Guest

    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)
     
    Evertjan., Oct 28, 2004
    #4
  5. Nancy Drew

    Maarten Guest

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




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

    >
    >
     
    Maarten, Oct 29, 2004
    #5
  6. 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" <> wrote in message
    news:eMkgd.3209$-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]" <> schreef in bericht
    > news:%23ifC%...
    > > http://www.aspfaq.com/2170
    > >
    > > --
    > > http://www.aspfaq.com/
    > > (Reverse address to reply.)
    > >
    > >
    > >
    > >
    > > "Nancy Drew" <> wrote in message
    > > news:...
    > >> 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
    > >>
    > >>

    > >
    > >

    >
    >
     
    Aaron [SQL Server MVP], Oct 29, 2004
    #6
  7. Nancy Drew

    Nancy Drew Guest

    excellent - the code works great. thannks maarten.



    "Maarten" <> wrote in message
    news:chcgd.2953$-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
    >
    >
     
    Nancy Drew, Oct 29, 2004
    #7
  8. Nancy Drew

    Guest

    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...
     
    , Nov 9, 2004
    #8
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?TGFzZXIgTHU=?=

    How to get the width and height of a image by its given URL?

    =?Utf-8?B?TGFzZXIgTHU=?=, Jun 1, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    954
    Scott Allen
    Jun 1, 2004
  2. Robert Mark Bram
    Replies:
    13
    Views:
    654
  3. Lois
    Replies:
    1
    Views:
    3,403
    Ryan Stewart
    Dec 27, 2004
  4. Robert Mark Bram

    Easy way to tell height and width of an image?

    Robert Mark Bram, Jul 7, 2003, in forum: Javascript
    Replies:
    7
    Views:
    119
  5. Ben
    Replies:
    9
    Views:
    417
    jdalton
    May 2, 2008
Loading...

Share This Page