If you love working with PHP but hate the GD library, you’ll love the Simple Image PHP class we’re releasing today. This class takes the headache out of dealing with images and features over 25 useful methods.
The class is incredibly simple to use. The following two lines will load image.jpg, flip it horizontally, rotate it 90 degrees, shrink it to fit within a 320×200 box, apply a sepia effect, convert it to a GIF, and save it to result.gif:
$img = new SimpleImage('image.jpg');
$img->flip('x')->rotate(90)->best_fit(320, 200)->sepia()->save('result.gif');
Here’s a list of the supported methods:
flip()– flips an image vertically or horizontallyrotate()– rotates an image at the specified angleauto_orient()– adjusts the orientation based on the image’s EXIF dataresize()– resizes an image to the specified width/heightfit_to_width()– proportionally resizes an image to the specified widthfit_to_height()– proportionally resizes an image to the specified heightbest_fit()– proportionally resizes an image to fit within the specified width/heightcrop()– crop an image from x1/y1 to x2/y2square_crop()– trim the image to a square and resize to the specified sizedesaturate()– convert the image to grayscaleinvert()– invert the imagebrightness()– adjust the image’s brightnesscontrast()– adjust the image’s contrastcolorize()– apply the colorize filteredges()– apply the edges filteremboss()– apply the emboss filtermean_remove()– apply the mean removal filterblur()– apply selective or gaussian blur to the imagesketch()– apply the sketch filtersmooth()– apply the smooth filterpixelate()– pixelate the image to blocks of the specified sizesepia()– apply a simulated sepia effectoverlay()– overlay one image onto another to create a watermark effecttext()– Add text to the image
Download
This project is actively maintained on GitHub. Please submit all issues and contributions to the project page. Licensed under both the MIT and the GNU GPL licenses.


Is it possible to change the file path for saving the image?
Hanna, just specify the full file name in the save() method.
Is it possible to have the
rotatemethod add a transparent background instead of an opaque one?Perfect! Exactly what I’ve been looking for, works like a charm. Many thanks for that cool class! :)
Hi, you have done a good job! I just want to have one more addition on this, that is can you have resize proportionally method implemented? Also it’ll be beautiful to have text manipulation class with various font style and shapes.
You can use
fit_to_width(),fit_to_height(), orbest_fit()to proportionally resize an image depending on your needs.