Hi, We have a e-com site and the dimensions of images are different depending on the product. This is OK on the product page, but on the list page its a problem at the widest an image can be is 90px without breaking the design. Of course we can't shrink to 90px on all as the aspect ratio will be out. Whats the best way of working out the aspect ratio on the fly so we can re-size the images correctly? Thanks
You can use ImageCFC or a something similar ...but I don't understand why you cannot resize? You are only constrained by one dimension, not two, so resizing should not be a problem... ?
Yes I could resize, but I'm not sure what the algo would be to make sure its in the correct aspect ratio?
<img width="90"> ? If you leave out the height attribute, the image will resize keeping it's aspect ratio. Not a bandwidth friendly way of doing it, but it works. Of course, you could also use imagecfc to resize upon upload and create an actual thumbnail file...
I didn't know HTML automatically re-sized the height if only width is declared - interesting! Yes as a "quick fix" it will work and then we have the fun of creating thumbnails for 2000+ products! Thanks for your expert help.
I'm dealing with this same issue and I too have resorted to just giving the width artibute a value in the <img> tag. Seems to work but its not the best way to do it. Especially when the height is much greater then the width in the original image. In my case I dont actually host the image file. I only allow the users to save the url address of their image/photo to my database. Then I use coldfusion to fill in the "src" artibute of the <img> tag. Looks like: <img src="#logourl#"> or <img src=" http://www.exampleimage.img"> Code (markup): once it hits the browser. So is there a better way to accomplish what "amaze" was asking, and is there anything i can do to better improve my situation without having to actually allow user to upload the image file to my server. You can check out the page at: http://www.unitedlocalbands.com/user_login/user_band_logo.cfm?orderby=groupname Thanks for your help.
You can use imagemagick. It's resize function fits the image into the dimensions you specify. (maintains aspect ratio/doesn't stretch). convert image.gif -resize 90x90 You really should not use the <img> width and height to "resize" an image. It's a waste of bandwidth, and most importantly, it doesn't antialias so your image will look pretty ugly. You really dont want that on a site that is showing off products.