Improve image thumbnail

And auto download apk for android
This commit is contained in:
toto
2022-02-16 16:32:05 +01:00
committed by Imperator
parent 673f0433ed
commit 0f2f5172ac
4 changed files with 180 additions and 2 deletions

46
thumbnail.php Normal file
View File

@ -0,0 +1,46 @@
<?php
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
$root = $_SERVER["DOCUMENT_ROOT"];
$directory = "/uploads/";
if(isset($_GET["file"])) {
$file = $root.urldecode($_GET["file"]);
$size = isset($_GET["size"]) ? $_GET["size"] : 100;
if(file_exists($file)) {
echo getthumbnail($file, $size);
exit();
}
else {
header("HTTP/1.1 400 File not Found");
echo $file." not Found";
exit();
}
}
function getthumbnail(string $file, int $size)
{
list($width, $height) = getimagesize($file);
// Create an Imagick object
$imagick = new Imagick($file);
// Function to set the background color
$imagick->setbackgroundcolor('rgb(0, 0, 0)');
// Use thumbnailImage function
$imagick->thumbnailImage($width*$size/$height, $size, true, true);
header("Content-Type: image/jpg");
// Display the output image
echo $imagick->getImageBlob();
}
?>