1 | <?php |
||
15 | class Thumbnail extends AbstractThumbnail |
||
16 | { |
||
17 | |||
18 | const SIZE_VERY_SMALL = 70; |
||
19 | const SIZE_SMALL = 116; |
||
20 | const SIZE_MEDIUM = 160; |
||
21 | const SIZE_LARGE = 434; |
||
22 | |||
23 | /** |
||
24 | * Prefix used for storing temporary files |
||
25 | */ |
||
26 | const TEMP_FILE_PREFIX = 'xbmc-video-server-thumbnail'; |
||
27 | |||
28 | /** |
||
29 | * @var int the thumbnail size |
||
30 | */ |
||
31 | private $_size; |
||
32 | |||
33 | /** |
||
34 | * @var ImageCache the cache |
||
35 | */ |
||
36 | private $_cache; |
||
37 | |||
38 | /** |
||
39 | * Class constructor |
||
40 | * @param string $thumbnailPath the thumbnail path. |
||
41 | * @param int $size the thumbnail size. Defaults to SIZE_SMALL and can be |
||
42 | * changed afterwards |
||
43 | */ |
||
44 | public function __construct($thumbnailPath, $size = self::SIZE_SMALL) |
||
51 | |||
52 | /** |
||
53 | * Returns the absolute path to a cached thumbnail or false if no cached |
||
54 | * copy exists |
||
55 | * @return string|false |
||
56 | */ |
||
57 | public function getPath() |
||
66 | |||
67 | /** |
||
68 | * Returns the URL to the thumbnail |
||
69 | * @return string |
||
70 | */ |
||
71 | public function getUrl() |
||
83 | |||
84 | /** |
||
85 | * @return string the URL to the original version of the image |
||
86 | */ |
||
87 | private function getOriginalUrl() |
||
93 | |||
94 | /** |
||
95 | * Generates and stores a cached copy of this thumbnail. It first retrieves |
||
96 | * the original image to a temporary location for processing. This is done |
||
97 | * because Kodi doesn't like the HTTP/1.0 requests that the built-in PHP |
||
98 | * image manipulation functions (as well as file_get_contents()) use. |
||
99 | */ |
||
100 | public function generate() |
||
127 | |||
128 | /** |
||
129 | * Determines the filename to be used for the thumbnail |
||
130 | * @return string |
||
131 | */ |
||
132 | private function getFilename() |
||
136 | |||
137 | /** |
||
138 | * Returns the temporary directory where images should be stored for |
||
139 | * processing. It will first try upload_tmp_dir and fall back to the |
||
140 | * system default if that directive has not been set. |
||
141 | * @return string |
||
142 | */ |
||
143 | private static function getTemporaryDirectory() |
||
152 | |||
153 | /** |
||
154 | * Factory method for creating an Imagine instance |
||
155 | * @return \Imagine\Gd\Imagine|\Imagine\Imagick\Imagine |
||
156 | */ |
||
157 | private function imagineFactory() |
||
166 | |||
167 | } |
||
168 |