Wwwebber's Blog

Php Script-Process, Display and Watermark all images in a Directory

Posted in free php scripts, image effects by wwwebber on December 13, 2009

I needed a bit of break from some large projects I’ve been working on so I made up a little script that will process, display and watermark all images in a directory. The script makes use of 2 classes. One class is a ImageViewer . This takes an image and watermerks it with whatever text you want.(font size and text is hard coded..so doesn’t work well for really small images…sorry just don’t have the time for that level of finesse at the moment)

The other class processes(DisplayImageDir) a directory by –it gets a list of all images in a given directory (anything with .jpg, .jpeg, .png, or .bmp)

The script will output a double columned display of all of the images in the directory with the watermark added!

You can download the scirpt

Here’s are some demo pages
http://www.mathwarehouse.com/code/php-scripts/imagewriter/
Images of Linear Equations

This script could definitely be improved and generalized. I simply wanted to make it easier for search engines and users of my site to be able to find, and if possibly download the many, many images I have over at Math Warehouse. However, I did want to ensure that there was a copyright watermark on each file.

The script works right out of the box, is open source and hopefully will be useful for someone.

This script ran on a Godaddy shared hosting account–about as budget as it gets so if you’re host doesn’t support the features for the script…it might be time for you to upgrade your account!

Also, note that I named one of the files .php5 to ensure that it was processed by php 5–this was necessary on teh GoDaddy server…you might need to rename the file as well as teh associated variable which is located in DisplayImageDir.class.php

Comments Off on Php Script-Process, Display and Watermark all images in a Directory