Resize images
Some times web sites require image resize, let’s say… upload, resize and display image. That process is harder to handle by PHP (internally) because resize an image require a lots of computers resources (CPU, memory, time), so for a good results there must exist a cache system, which simply is do not re-do what is done.
On work I need to do something like that and I was a little tired for rewrite my own class, so I google-up and I’ve a class that feed my needs. Easy to implement, just a few of lines to write for made it works!, and resize image is saved into a folder ( a cache system).
Another good issue that I’ve seen in this class is the possibility to emblemed water images.
Examples:
<?php
include “SmartImage.class.php”;$img = new SmartImage(
“newimages/new01.jpg”);
// Resize and save to file
// the true value means to cut the image
$img->resize(400, 220, true);
$img->addWaterMarkImage(“images/smartimage.gif”);
$img->saveImage(“newimages/new03.jpg”, 85);
?>
The above code will transform this image:

Into this:

I really like this class not only because works fine for me and is easy to implement, also I liked an very much this class for it license (LGPL) which gives me the freedom to include into my projects without share the code of my proyect (sometimes we cannot share the code, but I usually do). For that reason, most of my proyects are public domain or under BSD License.
Share and Enjoy:
These icons link to social bookmarking sites where readers can share and discover new web pages.

October 12th, 2007 at 4:46 pm
I wanna give thanks to Alessandro Coscia for this class…
I think most programmers should write useful class and share it…
November 14th, 2007 at 3:48 pm
So can you add a custom text on web pages using this class? It sounds good :).
November 14th, 2007 at 3:54 pm
You can add a watermark image.