Resizing images dynamically

After a long time i thought to post very interesting thing which i believe could be a great help for people who wanna develop scalable applications with lots of images.

I have often seen that when people upload images on websites, they tend to create thumbnails as to make those images appear better on websites. Even i used to do this but recently i analyzed that this method obviously solves our in-hand problem but let say if i want to change the design of my website in future and want different sized image. One way to solve this problem is to keep your original image and run scripts to resize all your images to desired size but i thought to solve this problem with a different approach which is to not resize the images at all and keep it as is.

Now the question is, how do i fit my images in my website?

To solve this problem i created a Codeigniter Class(However it can be used for other frameworks as well with some changes) which would resize my images on the fly. Lets see how: –

When i have to use this class, i can simply call it using

With this solution you don’t have to worry about creating different thumbnails for images as well as future design changes.

I hope this will solve your problems. Comments & suggestions are invited.

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to Top