blob: f620fc1fba485384c0fbaa08b7d652e38e9ce06f (
plain) (
blame)
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
|
<?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){
@imagefilter($imgFile, IMG_FILTER_GRAYSCALE);
ob_start();
@imagejpeg($imgFile);
$image = ob_get_contents();
ob_end_clean();
@imagedestroy($imgFile);
return $image;
}
return false;
}
}
?>
|