Dynamic Images resized to Proportional area

I needed a image that was dynamically driven to be displayed within a Proportional area (in width), I tried so many different tutorials to get it right and I just couldnt get it right... I was always missing something or it would execute the script correctly.

I needed a image that was dynamically driven to be displayed within a Proportional area (in width), I tried so many different tutorials to get it right and I just couldnt get it right... I was always missing something or it would execute the script correctly.
After so much attempts I thought to myself there had to be a better and easier way, and so I found it. Lets have a look at the source:

<img src="<%=(rs_mainart.Fields.Item("pix").Value)%>" width="250">

In this we can clearly see that at a recordset calls for the item (per usual) then set a width of (x) value. What this has done is set a maximum width and have the image height adjust to ratio of the width.

What have we accomplished here? Well, the last thing you want is an image to be stretched due to its constrained area. It doesnt look professional and can mess up your design. I have used this source for a magazine, so text would be wrapped around the image and now no matter what shape or size the image is the text would sit in preportion to the image.
Add a CSS to have text sit with padding around the image and your set. Now no matter what image is uploaded to the source, it would show in preportion and constrained width.

Comments

image_Thumbnailer

March 1, 2006 by Aron K
see: http://dmxtutorials.com/free/Image_Thumbnailer.htm

Thank you for an EXCELLENT solution...

April 7, 2006 by Mike Mitchell

THANK YOU!  This is such a simple solution, but it is very useful, and unbelievably elegant. You just fixed five VERY ugly pages that I had made before reading this.

Muchas Gracias.

You must me logged in to write a comment.