Professional Web Applications Themes

Picture Sizes - ASP Database

I have an asp page that retrieves various details from and Access table. One of the columns stores an image name and is written into the html as follows: Response.Write "<td width=200 height=200 valign=top><img border=0 src=../../gallery/" & rec1("picture") & "></td>" The image loads fine at runtime but many of the images are larger than 200x200. I know i can resize the image to 200x200 quite easily but that would lose its aspect ration. Is there a way to load the image so it would fit into the 200x200 cell but maintain its aspect ratio. Regards Paul...

  1. #1

    Default Picture Sizes

    I have an asp page that retrieves various details from and Access table. One
    of the columns stores an image name and is written into the html as follows:

    Response.Write "<td width=200 height=200 valign=top><img border=0
    src=../../gallery/" & rec1("picture") & "></td>"

    The image loads fine at runtime but many of the images are larger than
    200x200. I know i can resize the image to 200x200 quite easily but that
    would lose its aspect ration. Is there a way to load the image so it would
    fit into the 200x200 cell but maintain its aspect ratio.

    Regards

    Paul


    Popeye Guest

  2. #2

    Default Re: Picture Sizes

    "Popeye" <not> wrote in message
    news:H6D7d.1394$news.blueyonder.co.uk... 
    One 
    follows: 

    Try assigning " width='200'" to your "<img>" tag..


    McKirahan Guest

  3. #3

    Default Re: Picture Sizes

    Well, if you know it is always wider than it is tall, you can set width=200
    on the image tag, like McKirahan suggested.

    If it is not always portrait-oriented or square, then you may have to use
    some server-side checking of the image's dimensions beforehand, then either
    set the width or height to 200, depending on which is larger.

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

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




    "Popeye" <not> wrote in message
    news:H6D7d.1394$news.blueyonder.co.uk... 
    One 
    follows: 


    Aaron Guest

  4. #4

    Default Re: Picture Sizes


    "Aaron [SQL Server MVP]" <noraa> wrote in message
    news:phx.gbl... 
    > One 
    > follows: 
    >
    >[/ref]
    Thanks for the link, i've managed to get it to work by butchering the sample
    provided.

    Paul


    Popeye Guest

  5. #5

    Default Re: Picture Sizes



    Why not resample the image to fit inside the area you want (retaining aspect ratio, of course) and store
    the actual dimensions in the table - then there is no stretching/distortion, maximum display quality, minimum
    server load and no wasted bandwidth.

    --
    __________________________________________________ _____
    http://www.ammara.com/
    Image Handling Components, Samples, Solutions and Info
    DBPix 2.0 - lossless jpeg rotation, EXIF, asynchronous



    "Popeye" <not> wrote: 

    Exponent Guest

  6. #6

    Default Re: Picture Sizes

    It sounds like he's trying to avoid the hassle of cataloging the dimensions
    of every single image he will display. Can't say I blame him.





    "Exponent" <com> wrote in message news:41613534$.. 
    aspect ratio, of course) and store 
    stretching/distortion, maximum display quality, minimum 


    Aaron Guest

  7. #7

    Default Re: Picture Sizes



    The image info is already held in a convenient 'catalog' system, so it is trivial to update this with the
    dimensions for existing images, and to do so automatically for new records as they are added.

    Surely this is better than a server-side check each time the image is displayed ? or displaying the images
    stretched or squashed ?


    "Aaron [SQL Server MVP]" <noraa> wrote: 
    >aspect ratio, of course) and store 
    >stretching/distortion, maximum display quality, minimum 
    >
    >[/ref]

    Exponent Guest

  8. #8

    Default Re: Picture Sizes

    > The image info is already held in a convenient 'catalog' system,

    Are you talking about the file system? If so, have you made the assumption
    that he has all of the images on his own hard drive? Many of them might be
    on other servers, or even on his own FTP server where he doesn't have the
    luxury of running local scripts to get all of the information.

    A


    Aaron Guest

  9. #9

    Default Re: Picture Sizes




    Since the OP states: "I know i can resize the image to 200x200 quite easily", the images would appear to
    be accessible.


    "Aaron [SQL Server MVP]" <noraa> wrote: 
    >
    >Are you talking about the file system? If so, have you made the assumption
    >that he has all of the images on his own hard drive? Many of them might be
    >on other servers, or even on his own FTP server where he doesn't have the
    >luxury of running local scripts to get all of the information.
    >
    >A
    >
    >[/ref]

    Exponent Guest

  10. #10

    Default Re: Picture Sizes

    Then it must not be worth the effort (or surely he would be doing that).

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

     
    easily", the images would appear to 


    Aaron Guest

  11. #11

    Default Re: Picture Sizes


    No, the database (I referred to the image ‘info’), which already contains the location of the images, and
    from which the referring url is generated.

    "Aaron [SQL Server MVP]" <noraa> wrote: 
    >
    >Are you talking about the file system? If so, have you made the assumption
    >that he has all of the images on his own hard drive? Many of them might be
    >on other servers, or even on his own FTP server where he doesn't have the
    >luxury of running local scripts to get all of the information.
    >
    >A
    >
    >[/ref]

    Exponent Guest

  12. #12

    Default Re: Picture Sizes


     

    Well, in full he said: "I know i can resize the image to 200x200 quite easily but that would lose its aspect
    ratio".

    But of course, he *could* resize (or better, resample) the image to fit *inside* 200x200, while retaining
    the aspect ratio.

    ...and he can store the dimensions in the table at this time, then they can be included in the img tag,
    which allows the browser to complete page-layout before downloading all the images.

    ...and the images are served at final dislay resolution, i.e. maximum visual quality, minimum bandwidth.



    Exponent Guest

  13. #13

    Default That the way

    Use this simple Sub to calculate the WIDTH and HEIGHT of an image

    myImage = "DSC0199.JPG"

    ImgDimension(myImage)

    Response.Write "<img src=" & Chr(34) & myImage & Chr(34) & " width=" &
    Chr(34) & Cstr(iWidth) & Chr(34) & " height=" & CHR(34) & Cstr(iHeight) &
    Chr(34) & ">"

    Now you can play with the values. If > 200 then iWidth=200: iHeight=
    (200/4)*3 and so on.





    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


    John Guest

Similar Threads

  1. EPS File Sizes
    By Steve_Pecko@adobeforums.com in forum Adobe Illustrator Macintosh
    Replies: 6
    Last Post: August 4th, 04:21 PM
  2. Hi res PDF file sizes?
    By Alastair_Bruce@adobeforums.com in forum Adobe Indesign Windows
    Replies: 2
    Last Post: July 28th, 10:57 AM
  3. Different page sizes in one doc.
    By JenniferLLowe@adobeforums.com in forum Adobe Indesign Windows
    Replies: 1
    Last Post: June 29th, 10:06 PM
  4. CSS is different sizes
    By vin-E webforumsuser@macromedia.com in forum Macromedia Dreamweaver
    Replies: 4
    Last Post: July 16th, 05:40 PM
  5. Resolution sizes
    By Bill in forum Macromedia Dreamweaver
    Replies: 3
    Last Post: July 11th, 12:43 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139