aboutsummaryrefslogtreecommitdiffhomepage
path: root/inc/3rdparty/libraries/MOBIClass/ImageHandler.php
diff options
context:
space:
mode:
authorThomas Citharel <tcit@tcit.fr>2014-12-14 00:16:22 +0100
committerThomas Citharel <tcit@tcit.fr>2014-12-14 00:16:22 +0100
commitdc69d3e8d895c87f9d26c2d1309e40d6090d4c8d (patch)
tree3cc3bd960df403a6e0645afcd9e4f5bbb68bfc0e /inc/3rdparty/libraries/MOBIClass/ImageHandler.php
parent9c55ed0923273da886497cb62302a79622e34a74 (diff)
parent9f86454b48dec3c9ecfee8da224112eef0f61441 (diff)
downloadwallabag-dc69d3e8d895c87f9d26c2d1309e40d6090d4c8d.tar.gz
wallabag-dc69d3e8d895c87f9d26c2d1309e40d6090d4c8d.tar.zst
wallabag-dc69d3e8d895c87f9d26c2d1309e40d6090d4c8d.zip
merge epub with all the dev evolutions
Diffstat (limited to 'inc/3rdparty/libraries/MOBIClass/ImageHandler.php')
-rw-r--r--inc/3rdparty/libraries/MOBIClass/ImageHandler.php40
1 files changed, 40 insertions, 0 deletions
diff --git a/inc/3rdparty/libraries/MOBIClass/ImageHandler.php b/inc/3rdparty/libraries/MOBIClass/ImageHandler.php
new file mode 100644
index 00000000..bcb48e9f
--- /dev/null
+++ b/inc/3rdparty/libraries/MOBIClass/ImageHandler.php
@@ -0,0 +1,40 @@
1<?php
2
3class 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 $result = self::CreateImage($imgFile);
15 imagedestroy($imgFile);
16 return $result;
17 }
18 return false;
19 }
20 /**
21 * Create an image
22 * @param resource $img Create an image created with createimagetruecolor
23 * @return false|string False if failed, else the data of the image (converted to grayscale jpeg)
24 */
25 public static function CreateImage($img){
26 try{
27 imagefilter($img, IMG_FILTER_GRAYSCALE);
28
29 ob_start();
30 imagejpeg($img);
31 $image = ob_get_contents();
32 ob_end_clean();
33
34 return $image;
35 }catch(Exception $e){
36 return false;
37 }
38 }
39}
40?>