ThumbGen is a project mainly written in PHP, it's free.
Thumbnail generator with caching and watermark support
Thumbnail generator with caching and watermark support.
Load the core class in the PHP file that will output the thumbnail:
require_once('path_to/ThumbGen.class.php');
Create a new ThumbGen object:
$thumbGen = new ThumbGen();
Setup the ThumbGen object as needed and generate the thumbnail:
$thumbGen->getThumbnail('path_to/image.jpg');
Output the thumbnail image:
$thumbGen->outputThumbnail();
Note: If you want to use caching, make sure the cache
folder is writable.
In order to use the Watermark features you need to also load the Watermark plugin class:
require_once('path_to/ThumbGen.class.php'); require_once('path_to/Watermark.class.php');
Create a Watermark object:
$tgWatermark = new \ThumbGen\Watermark();
Setup the Watermark options:
$tgWatermark->setWatermark('path_to/watermark.png');
Apply the watermark to the thumbnail:
$tgWatermark->addWatermark($thumbGen);
Update the thumbnail with the watermarked version:
$thumbGen->updateThumbnailData($tgWatermark->getThumbnailData());
And finally, generate the thumbnail:
$thumbGen->outputThumbnail();
Note: The watermark image must be PNG.
Please see the examples for actual code.
Fixed the caching to use the set duration instead of being infinite (util the source image was modified);
Watermark: the setWatermark repetition doesn't need to be an array and include the padding when it's set to 'no-repeat'.
Copyright (c) 2011 Mihai Zaharie
License: CC BY-NC-SA 3.0