diff options
Diffstat (limited to 'inc/3rdparty/libraries/send2kindle/MOBIClass/ImageHandler.php')
-rw-r--r-- | inc/3rdparty/libraries/send2kindle/MOBIClass/ImageHandler.php | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/inc/3rdparty/libraries/send2kindle/MOBIClass/ImageHandler.php b/inc/3rdparty/libraries/send2kindle/MOBIClass/ImageHandler.php new file mode 100644 index 00000000..f620fc1f --- /dev/null +++ b/inc/3rdparty/libraries/send2kindle/MOBIClass/ImageHandler.php | |||
@@ -0,0 +1,28 @@ | |||
1 | <?php | ||
2 | |||
3 | class ImageHandler { | ||
4 | /** | ||
5 | * Download an image | ||
6 | * @param string $url Url to the image | ||
7 | * @return false|string False if failed, else the data of the image (converted to grayscale jpeg) | ||
8 | */ | ||
9 | public static function DownloadImage($url){ | ||
10 | $data = Http::Request($url); | ||
11 | $imgFile = @imagecreatefromstring($data); | ||
12 | |||
13 | if($imgFile !== false){ | ||
14 | @imagefilter($imgFile, IMG_FILTER_GRAYSCALE); | ||
15 | |||
16 | ob_start(); | ||
17 | @imagejpeg($imgFile); | ||
18 | $image = ob_get_contents(); | ||
19 | ob_end_clean(); | ||
20 | |||
21 | @imagedestroy($imgFile); | ||
22 | |||
23 | return $image; | ||
24 | } | ||
25 | return false; | ||
26 | } | ||
27 | } | ||
28 | ?> | ||