📱Add mobile support
This commit is contained in:
@@ -5,14 +5,14 @@ $filetype = "";
|
||||
$raw_image = NULL;
|
||||
|
||||
//get the image url
|
||||
if (isset( $_GET['i'] ) ) {
|
||||
$url = $_GET[ 'i' ];
|
||||
if (isset($_GET['i'])) {
|
||||
$url = $_GET['i'];
|
||||
} else {
|
||||
exit();
|
||||
}
|
||||
|
||||
//an image will start with http, anything else is sus
|
||||
if (substr( $url, 0, 4 ) != "http") {
|
||||
if (substr($url, 0, 4) != "http") {
|
||||
exit();
|
||||
}
|
||||
|
||||
@@ -31,22 +31,20 @@ $raw_imagex = imagesx($raw_image);
|
||||
$raw_imagey = imagesy($raw_image);
|
||||
|
||||
if ($raw_imagex >= $raw_imagey) {
|
||||
$dest_imagex = 300;
|
||||
$dest_imagey = intval(($raw_imagey / $raw_imagex) * $dest_imagex);
|
||||
$dest_imagex = 240; // Réduit de 300 à 240
|
||||
$dest_imagey = intval(($raw_imagey / $raw_imagex) * $dest_imagex);
|
||||
} else {
|
||||
$dest_imagey = 200;
|
||||
$dest_imagex = intval(($raw_imagex / $raw_imagey) * $dest_imagey);
|
||||
$dest_imagey = 160; // Réduit de 200 à 160
|
||||
$dest_imagex = intval(($raw_imagex / $raw_imagey) * $dest_imagey);
|
||||
}
|
||||
|
||||
$dest_image = imagecreatetruecolor($dest_imagex, $dest_imagey);
|
||||
|
||||
imagecopyresampled($dest_image, $raw_image, 0, 0, 0, 0, $dest_imagex, $dest_imagey, $raw_imagex, $raw_imagey);
|
||||
|
||||
header('Content-type: image/' . $filetype);
|
||||
header('Content-type: image/' . $filetype);
|
||||
if ($filetype = "jpg") {
|
||||
imagejpeg($dest_image,NULL,80); //80% quality
|
||||
imagejpeg($dest_image, NULL, 80); //80% quality
|
||||
} elseif ($filetype = "png") {
|
||||
imagepng($dest_image,NULL,8); //80% compression
|
||||
imagepng($dest_image, NULL, 8); //80% compression
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user