examples
try out this cool exampleswe start with different photos
let's create some thumbs
look how easy it works
<?php
require 'Thumbnailer.php';
// create objects
$thumb1=new Thumbnailer('photo1.jpg');
$thumb2=new Thumbnailer('photo2.jpg');
$thumb3=new Thumbnailer('photo3.jpg');
// small thumbs
$thumb1->thumbSquare(50)->save('photo1_thumb.jpg');
$thumb2->thumbSquare(50)->save('photo2_thumb.jpg');
$thumb3->thumbSquare(50)->save('photo3_thumb.jpg');
// larger thumbs
$thumb1->thumbSquare(100)->save('photo1_thumb.jpg');
$thumb2->thumbSquare(100)->save('photo2_thumb.jpg');
$thumb3->thumbSquare(100)->save('photo3_thumb.jpg');
// you can combine all the methods!
// look at that one, squared thumb with all round corners
// (you can specify which corners should be round)
$thumb1->thumbSquare(100)->round(Thumbnailer::ROUND_BOTTOM_LEFT, Thumbnailer::colorHex('#FFFFFF'))->save('photo1_thumb.jpg');
$thumb2->thumbSquare(100)->round(Thumbnailer::ROUND_TOP_LEFT | Thumbnailer::ROUND_BOTTOM_RIGHT, Thumbnailer::colorHex('#FFFFFF'))->save('photo2_thumb.jpg');
$thumb3->thumbSquare(100)->round(Thumbnailer::ROUND_ALL, Thumbnailer::colorHex('#FFFFFF'))->save('photo3_thumb.jpg');
// If your site's background is different than white
// you must override rounded corner's background.
// You can also modify the corner's radius! (default is 10)
//
// then save it wherever you want
$corners=Thumbnailer::ROUND_ALL;
$cornerColor=Thumbnailer::colorHex('#FF0000');
$cornerRadius=50;
$thumb1->thumbSymmetric(200)->round($corners, $cornerColor, $cornerRadius)->save('some_thumb.jpg');
?>
Square thumbs 50 pixel width
Square thumbs 100 pixel width
Square thumbs 100 pixel width with round corners
Symmetric thumbs with ratio keeped
Fixed size thumbs
easily create thumbs with fixed width and height
<?php
require 'Thumbnailer.php';
$thumb1=new Thumbnailer('photo_wide.jpg');
$thumb2=new Thumbnailer('photo_tall.jpg');
$thumb3=new Thumbnailer('photo_square.jpg');
$thumb1->thumbFixed(100,50)->save('1.jpg');
$thumb2->thumbFixed(50,100)->save('2.jpg');
$thumb3->thumbFixed(120,80)->save('3.jpg');
?>
Fixed size thumbs result
batch mode
create many thumbs in a moment! it's as easy as it looks
<?php
require 'Thumbnailer.php';
/**
* This is a callback function. It will be executed
* on every thumbnailer object in batch mode.
* Notice the ampersand & character before the function
* parameter. Remember not to forget it.
*
* This example will produce square thumbs of every
* photo with a #999999 color border around it.
* Have fun.
*/
function myfunc(& $thumb)
{
$thumb
->thumbSquare(100)
->border( Thumbnailer::colorHex('#999999') );
// all data collected from the return
// will be outputed as an array
// from the batch method
return $thumb->name;
}
/**
* Run batch mode.
*
* First parameter:
* callback function with working script
* Second parameter:
* mask for finding the photos
* (for more info look at http://php.net/glob/ help)
* Third parameter (optional):
* Directory to save thumbs to. If it is not defined
* thumbs must be saved by save() method in
* the callback function.
*/
$result=Thumbnailer::batch('myfunc', './in/*.jpg', './');
// $result contains parsed photos filenames
// Of course it could contain anything else you want
// for example boolean values to check if thumb
// for every photo was successfuly created.
?>
Put your own watermark
Text or image based (supports images with alpha channel too)Text based watermark
<?php
require 'Thumbnailer.php';
$thumb=new Thumbnailer('myPhoto.jpg');
$thumb->thumbSymmetric(200)->logoText('(c) mysite.com')->save('thumbWithWatermark.gif');
?>
Photo based watermark
<?php
require 'Thumbnailer.php';
$thumb=new Thumbnailer('myPhoto.jpg');
$thumb->thumbSymmetric(200)->logoPhoto('/images/mylogo.png')->save('thumbWithWatermark.gif');
?>
Picture effects
Grayscale effect
<?php
require 'Thumbnailer.php';
$thumb=new Thumbnailer('panda.jpg');
$thumb->thumbFixed(100,100)->effectGray()->save('thumb.jpg');
?>
You can combine all the methods with themselves, so feel free to explore!