forked from hetao29/slightphp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSThumbnail.php
More file actions
55 lines (52 loc) · 1.88 KB
/
SThumbnail.php
File metadata and controls
55 lines (52 loc) · 1.88 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
<?php
/*{{{LICENSE
+-----------------------------------------------------------------------+
| SlightPHP Framework |
+-----------------------------------------------------------------------+
| This program is free software; you can redistribute it and/or modify |
| it under the terms of the GNU General Public License as published by |
| the Free Software Foundation. You should have received a copy of the |
| GNU General Public License along with this program. If not, see |
| http://www.gnu.org/licenses/. |
| Copyright (C) 2008-2009. All Rights Reserved. |
+-----------------------------------------------------------------------+
| Supports: http://www.slightphp.com |
+-----------------------------------------------------------------------+
}}}*/
require_once(dirname(__FILE__).DIRECTORY_SEPARATOR."thumbnail/class.WMThumbnail.inc.php");
/**
* @package SlightPHP
*/
class SThumbnail extends SlightPHP\WMThumbnail{
/**
* Éú³ÉÎļþ
*
* @param $fileName
*/
var $image_type = 3;
public function genFile($fileName,$quality = 100) {
$image = parent::returnThumbnail();
$result = false;
if (!empty($image)){
switch ($this->image_type) {
case 1:
$result = imagegif($image, $fileName);
break;
case 2:
$quality = (int) $quality;
if ($quality < 0 || $quality > 100) {
$quality = 75;
} // end if
$result = imagejpeg($image, $fileName, $quality);
break;
case 3:
$result = imagepng($image, $fileName);
break;
case 15:
$result = imagewbmp($image, $fileName);
break;
} // end switch
}
return $result;
}
}