-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy paththumb.php
More file actions
68 lines (59 loc) · 1.78 KB
/
thumb.php
File metadata and controls
68 lines (59 loc) · 1.78 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
use Framework\CMS\Http\Request;
include 'bootstrap.php';
/*
Framework\CMS\Bootstrap::start(
new App\Thumb\Application([
'request' => new Request()
])
);*/
if (!isset($_GET['file'])) {
header('HTTP/1.0 404 Not Found');
exit('Not found');
}
class Operations extends \Bazalt\Thumbs\Operations
{
public function watermark(\Imagine\Image\ImageInterface $image, $options, $allOptions)
{
$imagine = new \Imagine\Gd\Imagine();
$wm = $imagine->open(__DIR__ . '/images/watermark.png');
$size = $image->getSize();
$wmSize = $wm->getSize();
list($x, $y) = explode(' ', $options);
if (!is_numeric($x)) {
$x = ($x == 'right') ? ($size->getWidth() - $wmSize->getWidth()) : 0;
if ($x < 0) $x = 0;
}
if (!is_numeric($y)) {
$y = ($y == 'bottom') ? ($size->getHeight() - $wmSize->getHeight()) : 0;
if ($y < 0) $y = 0;
}
$point = new \Imagine\Image\Point($x, $y);
return $image->paste($wm, $point);
}
public function grayscale(\Imagine\Image\ImageInterface $image, $options, $allOptions)
{
$image->effects()->grayscale();
return $image;
}
public function sepia(\Imagine\Image\ImageInterface $image, $options, $allOptions)
{
$image->effects()
->grayscale()
->colorize(new \Imagine\Image\Color('#643200'));
return $image;
}
}
$thumb = \Bazalt\Thumbs\Image::generateThumb(__DIR__ . $_GET['file'], new Operations());
if ($thumb) {
switch (pathinfo($thumb, PATHINFO_EXTENSION)) {
case 'png':
header('Content-Type: image/png');
break;
case 'jpg':
header('Content-Type: image/jpeg');
break;
}
readfile($thumb);
exit;
}