image question

Discussion in 'ASP General' started by Gonzosez, Feb 26, 2004.

  1. Gonzosez

    Gonzosez Guest

    I need to resize images to a fixed width.
    How can I hold the aspect ratio?
    Thanks
     
    Gonzosez, Feb 26, 2004
    #1
    1. Advertising

  2. Gonzosez

    Ray at Guest

    Decrease the height by the same percentage.

    iCurrentWidth = 100
    iCurrentHeight = 54
    iDesiredWidth = 70
    iPercentDecreased = iDesiredWidth/iCurrentWidth
    iNewHeight = CInt(iCurrentHeight * iPercentDecreased)

    Ray at work


    "Gonzosez" <> wrote in message
    news:enkbu0H$...
    > I need to resize images to a fixed width.
    > How can I hold the aspect ratio?
    > Thanks
    >
    >
     
    Ray at, Feb 26, 2004
    #2
    1. Advertising

  3. Gonzosez

    Gonzosez Guest

    How do I determine the orginal size?
    "Ray at <%=sLocation%> [MVP]" <myfirstname at lane34 dot com> wrote in
    message news:OFUSz6H$...
    > Decrease the height by the same percentage.
    >
    > iCurrentWidth = 100
    > iCurrentHeight = 54
    > iDesiredWidth = 70
    > iPercentDecreased = iDesiredWidth/iCurrentWidth
    > iNewHeight = CInt(iCurrentHeight * iPercentDecreased)
    >
    > Ray at work
    >
    >
    > "Gonzosez" <> wrote in message
    > news:enkbu0H$...
    > > I need to resize images to a fixed width.
    > > How can I hold the aspect ratio?
    > > Thanks
    > >
    > >

    >
    >
     
    Gonzosez, Feb 26, 2004
    #3
  4. Gonzosez

    Ray at Guest

    If using classic ASP, which I can assume you are if you're in this group,
    you need a server-side component to determine this. Here is a list of some
    links to components you can buy.
    http://www.aspfaq.com/show.asp?id=2170

    Ray at work


    "Gonzosez" <> wrote in message
    news:ueaRb$H$...
    > How do I determine the orginal size?
    > "Ray at <%=sLocation%> [MVP]" <myfirstname at lane34 dot com> wrote in
    > message news:OFUSz6H$...
    > > Decrease the height by the same percentage.
    > >
    > > iCurrentWidth = 100
    > > iCurrentHeight = 54
    > > iDesiredWidth = 70
    > > iPercentDecreased = iDesiredWidth/iCurrentWidth
    > > iNewHeight = CInt(iCurrentHeight * iPercentDecreased)
    > >
    > > Ray at work
    > >
    > >
    > > "Gonzosez" <> wrote in message
    > > news:enkbu0H$...
    > > > I need to resize images to a fixed width.
    > > > How can I hold the aspect ratio?
    > > > Thanks
    > > >
    > > >

    > >
    > >

    >
    >
     
    Ray at, Feb 26, 2004
    #4
  5. Gonzosez

    Roland Hall Guest

    "Gonzosez" wrote:
    : How do I determine the orginal size?

    You can do it on the client-side.

    This will not be the way you will want to use it but it will contain all the
    elements to convert it for your needs.
    Click on the image link and it will create a new image based on the defined
    'width', passed as an argument. I am passing 40 for the first image and 200
    for the second. If all images need a fixed width, then just set that in
    your function. I have it commented out right now in mine.

    http://kiddanger.com/lab/imgsize.html

    HTH...

    --
    Roland Hall
    /* This information is distributed in the hope that it will be useful, but
    without any warranty; without even the implied warranty of merchantability
    or fitness for a particular purpose. */
    Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
    WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
    MSDN Library - http://msdn.microsoft.com/library/default.asp
     
    Roland Hall, Feb 27, 2004
    #5
  6. Not so! Don't remember where I found this but if you're using IIS 5.0 this
    ought to work...(at least, it does for me)

    Function GetScaledImageDimensions(strPicturePath, imgWidth, imgHeight)
    dim picture, actualWidth, actualHeight, decProportion
    '--- as inputs, imgWidth and imgHeight are used as target sizes.
    '--- if imgWidth > 0 then imgHeight is adjusted proportionately, and vice
    versa.
    '--- to return the actual width and height, leave both at zero
    On Error Resume Next
    Set Picture = LoadPicture(strPicturePath)
    If Err <> 0 Then
    imgWidth = 0
    imgHeight = 0
    Else
    actualWidth = Round(Picture.Width / 26.5)
    actualHeight = Round(Picture.Height / 26.5)
    if imgWidth > 0 and imgHeight = 0 then
    decProportion = imgWidth / actualWidth
    elseif imgWidth = 0 and imgHeight > 0 then
    decProportion = imgHeight / actualHeight
    else
    decProportion = 1
    end if
    imgWidth = Round(actualWidth * decProportion)
    imgHeight = Round(actualHeight * decProportion)
    End If
    Set Picture = nothing
    End Function



    --
    William Morris
    Product Development, Seritas LLC
    Kansas City, Missouri


    "Ray at <%=sLocation%> [MVP]" <myfirstname at lane34 dot com> wrote in
    message news:OMn98CI$...
    > If using classic ASP, which I can assume you are if you're in this group,
    > you need a server-side component to determine this. Here is a list of

    some
    > links to components you can buy.
    > http://www.aspfaq.com/show.asp?id=2170
     
    William Morris, Feb 27, 2004
    #6
  7. Gonzosez

    Ray at Guest

    Oops. :]

    Ray at work

    "William Morris" <> wrote in
    message news:c1ogen$1lnhoh$-berlin.de...
    > Not so! Don't remember where I found this but if you're using IIS 5.0

    this
    > ought to work...(at least, it does for me)
    >
    > Function GetScaledImageDimensions(strPicturePath, imgWidth, imgHeight)
    > dim picture, actualWidth, actualHeight, decProportion
    > '--- as inputs, imgWidth and imgHeight are used as target sizes.
    > '--- if imgWidth > 0 then imgHeight is adjusted proportionately, and vice
    > versa.
    > '--- to return the actual width and height, leave both at zero
    > On Error Resume Next
    > Set Picture = LoadPicture(strPicturePath)
    > If Err <> 0 Then
    > imgWidth = 0
    > imgHeight = 0
    > Else
    > actualWidth = Round(Picture.Width / 26.5)
    > actualHeight = Round(Picture.Height / 26.5)
    > if imgWidth > 0 and imgHeight = 0 then
    > decProportion = imgWidth / actualWidth
    > elseif imgWidth = 0 and imgHeight > 0 then
    > decProportion = imgHeight / actualHeight
    > else
    > decProportion = 1
    > end if
    > imgWidth = Round(actualWidth * decProportion)
    > imgHeight = Round(actualHeight * decProportion)
    > End If
    > Set Picture = nothing
    > End Function
    >
    >
    >
    > --
    > William Morris
    > Product Development, Seritas LLC
    > Kansas City, Missouri
    >
    >
    > "Ray at <%=sLocation%> [MVP]" <myfirstname at lane34 dot com> wrote in
    > message news:OMn98CI$...
    > > If using classic ASP, which I can assume you are if you're in this

    group,
    > > you need a server-side component to determine this. Here is a list of

    > some
    > > links to components you can buy.
    > > http://www.aspfaq.com/show.asp?id=2170

    >
    >
     
    Ray at, Mar 1, 2004
    #7
    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. Jerry J
    Replies:
    0
    Views:
    547
    Jerry J
    Jul 18, 2003
  2. Mike John
    Replies:
    0
    Views:
    515
    Mike John
    Jul 28, 2003
  3. Gary B

    Image can't hold an image?

    Gary B, Jul 31, 2003, in forum: ASP .Net
    Replies:
    3
    Views:
    350
    Steve C. Orr, MCSD
    Aug 1, 2003
  4. Jim Hammond
    Replies:
    1
    Views:
    488
    Oliver
    Nov 13, 2003
  5. Laszlo Zsolt Nagy
    Replies:
    1
    Views:
    1,366
    Kartic
    Jan 26, 2005
Loading...

Share This Page