ImageBooth: Multilayered Image Manipulation in PHP

I’m going to be releasing documentation on my development framework, Datalus, in the near future… but before that, I’ll be releasing a few examples using the utility libraries from it.

My first example uses a stacked imaging framework built on top of GD who’s goal is to implement the feature set of photoshop 3. It may only be to about 30% of that goal, but it’s well past useful.

So let’s take this some images:


Then we’ll write a script to combine these images:

require('./ImageBooth.php');

    $raw_image = imagecreatefromjpeg('./captcha.jpg');
    $overlay_image = imagecreatefrompng('./captcha2.png');
    $checks = imagecreatefrompng('./checks.png');
    $image = ImageBooth::newImage(70, 200);
    $image->newLayer($raw_image, 'base');
    $image->newLayer($checks, 'checks');
    $image->newLayer($overlay_image, 'overlay');
    $image->filter('blur', array('amount'=>'400'));
    $image->operate('color_replace', array('origin_color'=>'333388', 'destination_color'=>'CC0000'));
    $image->operate('brightness_contrast', array('brightness_adjustment'=>-20, 'contrast_adjustment'=>20));
    $image->operate('negative');
    $image->selectLayer('checks');
    $image->transform('rotate', array('angle'=>15));
    $image->resize(400, 200);
    $image->resizeCanvas(500, 500);
    $image->dumpToBrowser();

Now check out the result:

That’s it. Download it.

  • steve

    Nice work, Abbey! I’m gonna use this. 🙂