A lot of PHP developers (both on the PHP4 and PHP5 side) need image transformation operations for various tasks, the most mundane of which are the proportional resizing and watermarking. Most of them strive to make their projects and scripts run on as many platforms and evironments as possible. You can find various scripts about image transforming operations utilizing all the availble environments, but they lack a centralized approach towards using them. The best thing you might get is PEAR::Image_Transform, but it is still in its alpha stage and the latest release was more than year and a half ago. Since more of the recent projects I was involved in required such image transforming functionality that will work on various platforms and enviroments, I decided to create the Asido library. Asido is open-source and its LGPL license allows you to place the class in your proprietary PHP projects (http://www.opensource.org/licenses/lgpl-license.php).
Asido offers the following functionality:
Installation is pretty easy: virtually there’s none.
All you need is to include the
and that’s it – you are good to go. You may include
it by directly specifying the path to the file, or by using
include_path – it will not matter.
Here’s a quick example:
<?php /** * Set the path to the Asido library */ include('./../../asido/dev/class.asido.php'); /** * Use the GD driver */ asido::driver('gd'); /** * Create an Asido_Image object */ $i1 = asido::image( 'the-source-image.jpg', 'filename-with-which-you-want-to-save-the-result.png' ); /** * Watermark it */ asido::watermark($i1, 'put-the-watermark-image-here.png'); /** * Resize it proportionally to make it fit inside a 400x400 frame */ asido::resize($i1, 400, 400, ASIDO_RESIZE_PROPORTIONAL); /** * Save it and overwrite the file if it exists */ $i1->save(ASIDO_OVERWRITE_ENABLED); ?>