improve the thumbnail hack
This commit is contained in:
parent
e66fcf3e88
commit
3b6bbd3063
1 changed files with 11 additions and 6 deletions
|
@ -1,9 +1,11 @@
|
|||
<?php
|
||||
|
||||
#echo "TODO: create thumbnail for ".$_GET["id"]." here";
|
||||
function log_error(string $message){
|
||||
file_put_contents('../php_errors.log', $message.PHP_EOL , FILE_APPEND | LOCK_EX);
|
||||
}
|
||||
|
||||
$width = 100;
|
||||
$height = 100;
|
||||
$width = 200;
|
||||
$height = 200;
|
||||
$quality = 90;
|
||||
|
||||
$thumb = getcwd() . $_GET["id"];
|
||||
|
@ -16,11 +18,14 @@ if (is_file($img)) {
|
|||
$imagick->cropThumbnailImage($width, $height);
|
||||
$imagick->setImagePage(0, 0, 0, 0);
|
||||
if (file_put_contents($thumb, $imagick) === false) {
|
||||
throw new Exception("Could not put contents.");
|
||||
log_error("Could not put contents.");
|
||||
}
|
||||
return true;
|
||||
|
||||
header("Content-type: image/jpeg");
|
||||
echo $imagick;
|
||||
exit;
|
||||
} else {
|
||||
throw new Exception("No valid image provided with {$img}.");
|
||||
log_error("No valid image provided with {$img}.");
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue