-
Notifications
You must be signed in to change notification settings - Fork 6
/
README
37 lines (27 loc) · 933 Bytes
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
*** 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');