examples

try out this cool examples

we start with different photos

photo 3 photo 2 photo 1

let's create some thumbs

look how easy it works
<?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(5Thumbnailer::colorHex('#FFFFFF'), Thumbnailer::BOTTOM_LEFT)->save('photo1_thumb.jpg');
$thumb2->thumbSquare(100)->round(5Thumbnailer::colorHex('#FFFFFF'), Thumbnailer::TOP_LEFT Thumbnailer::BOTTOM_RIGHT)->save('photo2_thumb.jpg');
$thumb3->thumbSquare(100)->round(5Thumbnailer::colorHex('#FFFFFF'), Thumbnailer::ALL)->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
$cornerRadius=10;
$cornerColor=Thumbnailer::colorHex('#FF0000');
$corners=Thumbnailer::ROUND_ALL;

$thumb1->thumbFixed(120,90)->round($cornerRadius$cornerColor$corners)->save('some_thumb.jpg');

?>

Square thumbs 50 pixel width

  • photo 3
  • photo 2
  • photo 1

Square thumbs 100 pixel width

  • photo 3
  • photo 2
  • photo 1

Square thumbs 100 pixel width with round corners

  • photo 3
  • photo 2
  • photo 1

Symmetric thumbs with ratio keeped

  • photo 2
  • photo 1
  • photo 3

Fixed size thumbs

easily create thumbs with fixed width and height
<?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

  • photo 1
  • photo 2
  • photo 3

batch mode

create many thumbs in a moment! it's as easy as it looks
<?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)->round()->save('thumbs'.$thumb->filename);

    
// all data collected from the return
    // will be outputed as an array
    // from the batch method
    
return $thumb->file;
}

/**
 * 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)
 */
$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.

print '<pre>';
print_r($result);
print 
'</pre>';

?>

Put your own watermark

Text or image based (supports images with alpha channel)

Custom watermark using TrueType UTF-8 font. TrueType font is required.

<?php
$thumb
=Thumbnailer::create('myPhoto.jpg');

// you can control text overall position using logoAlign method
// default watermark position is bottom left
$thumb->logoAlign(Thumbnailer::TOP_LEFT);
$thumb->logoAlign(Thumbnailer::TOP_RIGHT);
$thumb->logoAlign(Thumbnailer::BOTTOM_LEFT);
$thumb->logoAlign(Thumbnailer::BOTTOM_RIGHT);
$thumb->logoAlign(Thumbnailer::CENTER);

$thumb->thumbSquare(200)->logoText('(c) mysite.com''./arial.ttf');
$thumb->header();
$thumb->save();

// everything can be done using chaining
// in one line of code
Thumbnailer::create('myPhoto.jpg')->thumbSquare(200)->logoAlign(Thumbnailer::CENTER)->logoText('watermark''./arial.ttf')->header()->save();

?>

Photo based watermark

<?php
// chaining is fun!
Thumbnailer::create('myPhoto.jpg')
    ->
thumbSquare(100)
    ->
logoAlign(Thumbnailer::CENTER)
    ->
logoPhoto('watermark.jpg')
    ->
header()
    ->
save();

?>

Loading photos from remote location

<?php
$thumb
=new Thumbnailer('http://remote.location.com/photos/photo.jpeg');

// example display
$thumb->thumbFixed(200,90);
$thumb->header();
$thumb->save();

?>

Picture effects

Grayscale effect

<?php
$thumb
=new Thumbnailer('panda.jpg');
$thumb->thumbFixed(100,100)->effectGray()->save('thumb.jpg');

?>
  • photo 1

You can combine all the methods with themselves, so feel free to explore!

Thumbs