mirror of
https://github.com/wallabag/wallabag.git
synced 2025-07-22 17:18:37 +00:00
use directly MOBIClass
This commit is contained in:
parent
c70bfefc68
commit
fb9df0c269
47 changed files with 309 additions and 1551 deletions
40
inc/3rdparty/libraries/MOBIClass/ImageHandler.php
vendored
Normal file
40
inc/3rdparty/libraries/MOBIClass/ImageHandler.php
vendored
Normal file
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
|
||||
class ImageHandler {
|
||||
/**
|
||||
* Download an image
|
||||
* @param string $url Url to the image
|
||||
* @return false|string False if failed, else the data of the image (converted to grayscale jpeg)
|
||||
*/
|
||||
public static function DownloadImage($url){
|
||||
$data = Http::Request($url);
|
||||
$imgFile = @imagecreatefromstring($data);
|
||||
|
||||
if($imgFile !== false){
|
||||
$result = self::CreateImage($imgFile);
|
||||
imagedestroy($imgFile);
|
||||
return $result;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Create an image
|
||||
* @param resource $img Create an image created with createimagetruecolor
|
||||
* @return false|string False if failed, else the data of the image (converted to grayscale jpeg)
|
||||
*/
|
||||
public static function CreateImage($img){
|
||||
try{
|
||||
imagefilter($img, IMG_FILTER_GRAYSCALE);
|
||||
|
||||
ob_start();
|
||||
imagejpeg($img);
|
||||
$image = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
return $image;
|
||||
}catch(Exception $e){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
Loading…
Add table
Add a link
Reference in a new issue