If you use WordPress and you are blogging about something which requires a personalized image for every post such as Gadget blogs or you want to use different images for every post you have for illustration purpose only like what we commonly found on the newspaper blogs, I think it’s a good idea to list the link to each post with an image attached to a particular post displayed along with the postname and if necessary with the excerpt on it.

Okay, there is a problem displaying that kind of layout on your page if you don’t have images with the same size attached to each post you have. It won’t be big problem if you have the same ratio dimension on all of your images, resizing it with your CSS code will give the intended layout – it’s acceptable, even sometimes the hardcoded-resized image will get a little bit jagged, but if you have an image which has a different ratio dimension, the story will be different.

There is only one solution to solve the issue if you’re not intended to upload images with the same ratio dimension. The solution is to generate a new image with the new size. The logic is simple, resize it and if necessary, crop it.
How we’re going to do that? Of course with the help of phpGD library. Is there any function wrapper available to make the job easier?

Yes! It’s called “Smart Image Resizer” created by Joe Lencioni.

IT’s great for grabbing pictures from video and online sources, then displaying them in your blog. One of the issues is of course the scale and the size of the images and it’s extremely important that you manage these correctly in order to maintain the speed of your site. It’s easy to get carried aways with using videos and images in your post but remember they are significantly bigger than even a large amount of text. I’ve inserted lots of images from a free trial of BBC iPlayer that I tested, even when saved as JPEGs they increased the size of every post significantly.

But you have to know that it’s not a plugin, it’s basically a .php file so you need to do the setup
manually. Based on the description at the comment section of the file, this .php file can be used to resizes images, intelligently sharpens, crops based on width:height ratios, color fills transparent GIFs and PNGs, and caches variations for optimal performance – just perfect to do the job, at least for me.

This file requires PHP 5.1.0+ and GD installed.
SETTING UP THE FILE
Download the image.php file from here.
Extract the zipped file then place it on your /wp-content/uploads/ directory or something else you would like it to be.
With the assumption that you place the image.php file on /wp-content/uploads/, create a folder called “imagecache” under /wp-content/uploads/.
Make your “imagecache” directory writable by the web server (usually chmod 775).
Done!
TESTING IT
Put an image under your /wp-content/uploads/ directory. Pick the reasonably large one, for example 1024×768 so you can easily see the different between the original and the processed one.   It should work the same if you store it centrally or from a distributed server.  If it’s a popular image you may find investing in a few proxies to store them or perhaps a high powered FTP server.
Rename it to raw.jpg or any other name.
Open your browser then try these url combinations:
/wp-content/uploads/image.php/processed.jpg?width=300?=/wp-content/uploads/raw.jpg
/wp-content/uploads/image.php/processed.jpg?width=300&cropratio=1:1?=/wp-content/uploads/raw.jpg

Go ahead and try with your own url combination.

The following images are the result of Joe Lencioni’s image.php file applied on an image of this blog. You can right click them to check the image properties.

Leave a Reply

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