Skip to content

binho/php-thumb-library-watermark-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

*** ABOUT ***

A water mark plugin for PHP Thumb Library <http://phpthumb.gxdlabs.com>

*** INSTRUCTIONS ***

Just put gd_watermark.inc.php on your thumb_plugins directory.

*** USAGE ***

try {
        $thumb = PhpThumbFactory::create($file_path);
} catch (Exception $e) {
        die('Opsss! Something wrong: '.$e->getMessage());
}

$info = getimagesize($file_path);
$image_width  = intval($info[0]);
$image_height = intval($info[1]);

$is_portrait = false;
if ($image_height > $image_width) {
        $is_portrait = true;
}

if ($is_portrait) {
        $thumb->adaptiveResizeQuadrant(1024, 768, 'T');
        $thumb->crop(0, 0, 1024, 768);
} else {
        $thumb->adaptiveResize(1024, 768);
        $thumb->cropFromCenter(1024, 768);
}

$watermark = dirname(__FILE__).'/../images/watermark.png';

$thumb->createWatermark($watermark, 10, 10); /* margin bottom 10px and margin right 10px */
$thumb->save('/path/to/save/image.jpg');

About

Plugin to add a water mark on picture

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages