Home » Linux » PHP class using Imagick – resize, reflect or drop shadow

PHP class using Imagick – resize, reflect or drop shadow

Imagick used to generate reflectionI’ve been spending a bit of time getting to know PHP classes over the Christmas holiday, and I’ve written a couple to test out my knowledge.
The first is an image uploading class, which checks for various problems with files prior to moving them to a destination directory. It checks:

  • that the file actually exists
  • the size to ensure it doesn’t exceed a predetermined maximum
  • that the destination directory exists and is writable
  • that the file is actually a photo file
  • to see that the photo is in an accepted format (tif, jpg, gif, png)

before moving the file. The next class gives various options for manipulating the image, resizing, rounding corners, adding a reflection etc. all using the Imagick class, which is installed with php5-imagick (available from the ubuntu repos and other reputable linux software emporiums!). The reflection and drop shadow parts of the class owe a great deal to Mikko Koppanen who provides some great Imagick examples and code snippets on his blog. I’ve uploaded the classes, including an index file that can be used as an example in the absence of proper documentation!

I’ve uploaded a working version of the test files shown below as a demo to a website of mine: try it here.

Available to dowload as a zip archive including the four empty directories the example script needs to run. Any suggestions for improvement gladly received.

2 thoughts on “PHP class using Imagick – resize, reflect or drop shadow

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>