Plugins GD Reflection

masterexploder edited this page Sep 13, 2010 · 2 revisions

The GD Reflection plugin allows you to create those fancy Apple-style reflections for your images… granted it’s not so much an Apple thing anymore as a general Web 2.0 thing, but it’s fun anyway. Here’s a sample:

Usage

Usage is pretty easy… you’ve got only one function call:
createReflection($percent, $reflection, $white, $border, $borderColor)

Here’s what all that means:

  • $percent – What percentage of the image to create the reflection from
  • $reflection – What percentage of the image height should the reflection height be. i.e. If your image is 100 pixels high, and you set reflection to 40, the reflection would be 40 pixels high.
  • $white – How transparent (using white as the background) the reflection should be, as a percent
  • $border – Whether a border should be drawn around the original image (default is true)
  • $borderColor – The hex value of the color you would like your border to be (default is #a4a4a4)

And, here’s the code that generated the above (taken from the examples folder in the release):

<?php

require_once '../ThumbLib.inc.php';

$thumb = PhpThumbFactory::create('test.jpg');
$thumb->adaptiveResize(250, 250)->createReflection(40, 40, 80, true, '#a4a4a4');
$thumb->show();

?>

It’s that easy!

Requirements

The only thing this plugin requires is that you use the GD implementation of the library.