Resize Image or Crop Image with Joe Lencioni’s Smart Image Resizer, WordPress Setup
Posted by Daniel - 6,236 Views
UPDATE: I just created a WordPress plugin called smartimageresizer to get an easy use of this Smart Image Resizer functionality into your WordPress post. Click here to check it.
__________________________
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.
Oh man, it’s hard to describe it with words but what I am trying to say is displaying the link to a post with a layout format as shown on the image at the leftside.
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.
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.
- 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.
![]() |
![]() |
| w=300 cropratio= none | w=200 cropratio=1:1 |
click here for the original image
If you done it correctly, you will see the processed image displayed on your browser. You can right click the image then select properties to check the attributes. You will see that the image location is the same with the url on the address bar of your browser. If something goes wrong, the error message will be displayed on the browser.
Let me know when you have problems setting up the file. You can either email me or put it on the comment section. I prefer the 2nd one though :)
Model: Joice Mewengkang - a friend.
UPDATE: I just created a plugin called smartimageresizer to get an easy use of this functionality. Click here to check it.
__________________________
The following posts are programmatically considered as related to the current post by YARPP Plugin:
- SmartImageResizer Plugin, WordPress plugin based on Joe Lencioni’s Smart Image Resizer
- Resizing image on the fly with ASP.NET using the System.Drawing namespace
- ContuttoPDF (Wordpress Plugin to convert your Content to PDF)
- Wordpress, How to insert the Gravatar icon into the comment section
- Customizing the PDF file created with ContuttoPDF Wordpress Plugin
Related posts brought to you by Yet Another Related Posts Plugin.
Latest from Programming
- Microsoft Excel Import External Data Problem: When Microsoft Query doesn’t recognize some of your parameters
- SmartImageResizer Plugin, WordPress plugin based on Joe Lencioni’s Smart Image Resizer
- Resize Image or Crop Image with Joe Lencioni’s Smart Image Resizer, WordPress Setup
- Free Softwares to help you learn Regular Expression or to enhance your RegEx skill
- ConsoleProgressBar - Simple Progress Bar Function for your VB.Net Console Application
3 Responses to “Resize Image or Crop Image with Joe Lencioni’s Smart Image Resizer, WordPress Setup”
Leave a Reply
Latest Blog Entries
- Sweet Home 3D, a free home design software
- 26x Optical Zoom on a Compact Digital Camera?
- Windows 7 Release Candidate is now available
- Microsoft Excel Import External Data Problem: When Microsoft Query doesn’t recognize some of your parameters
- The Lack of Chances is the Source of Poverty, Can we make a different?
- SmartFTP Client is no longer Free. What would be the best replacement for it?
- Kantaris Media Player, The most suitable Free Media Player on my Audio Environment
Categories
Neighbours and Friends
- Anti Teori
- Busby SEO Test Page
- Deny Sri
- Digital Media Convert
- Freeware Maniac
- Oeroek
- RidhoCyber
- Suraja Web
Comments - Thanks Guys :)
Therese Lachance: Hi, Any idea how to have ContuttoPDF fetch the correct page language?
Marlena Albu: Super Blog, Dude! I am constantly on the watch for new and interesting sites and postings about audio equipment… which is what...
tresloukadu: yo how did u fixed when the tags shows <? and it shows < “& l t ; ” ?? please send me an email.
Sean: This is a great piece of code and thanks for adding the updates. Sean’s last blog post: Not All Text Message Marketing Is Created...
rodhy: Thank for your code, it very usefull for me. best regard.
Most Popular Entries
- Passing arguments to your VB.NET console application
- ConsoleProgressBar - Simple Progress Bar Function for your VB.Net Console Application
- ASCII To PDU Converter (Convert ASCII to PDU and vice versa)
- An example: Using CPort Delphi Component to read data from your cellphone
- Microsoft Excel Import External Data Problem: When Microsoft Query doesn’t recognize some of your parameters
Software Collections
- Sweet Home 3D, a free home design software
- SmartFTP Client is no longer Free. What would be the best replacement for it?
- Kantaris Media Player, The most suitable Free Media Player on my Audio Environment
- TCPView for Windows, Tool to check TCP and UDP Connections on your system
- The Code Snippet Plugin, my favourite syntax highlighter plugin for WordPress
Blogging Related Stuff
- Change the WordPress permalink structure to the best format, and yes it’s a little bit scary :D
- Something is wrong, the Google Search Result from my blog looks bad, don’t laugh please :D
- Several tips to reduce Blog Noise, especially when your blog covers more than one niche
- How to remove your indexed pages or even your entire site from Google and Yahoo!




















March 3rd, 2009 at 9:56 pm
I get the following error msg:
Fatal error: Call to undefined function add_filter() in /home/myopenth/public_html/wp-content/uploads/image.php on line 12
I did exactly as U mentioned !
July 3rd, 2009 at 7:27 pm
[…] reading here: Resize Image or Crop Image with Joe Lencioni’s Smart Image Resizer, WordPress Setup | averagecoder Tags: plugins Comments0 Leave a Reply Click here to cancel […]
July 5th, 2009 at 9:23 pm
omfg, I’ve been looking for this for so long. BLESS YOUR HEART. Keep up the good work. I could just kiss you.