2019-12-05 13:11:18 +00:00
|
|
|
<?php
|
2019-12-05 17:52:48 +00:00
|
|
|
|
2019-12-11 22:12:00 +00:00
|
|
|
function log_error(string $message){
|
|
|
|
file_put_contents('../php_errors.log', $message.PHP_EOL , FILE_APPEND | LOCK_EX);
|
|
|
|
}
|
2019-12-05 17:52:48 +00:00
|
|
|
|
2019-12-11 22:12:00 +00:00
|
|
|
$width = 200;
|
|
|
|
$height = 200;
|
2019-12-05 17:52:48 +00:00
|
|
|
$quality = 90;
|
|
|
|
|
|
|
|
$thumb = getcwd() . $_GET["id"];
|
|
|
|
$img = str_replace("thumbnails", "staticimages", $thumb);
|
|
|
|
if (is_file($img)) {
|
2019-12-21 18:08:40 +00:00
|
|
|
try {
|
|
|
|
$imagick = new Imagick($img);
|
|
|
|
$imagick->setImageFormat('jpeg');
|
|
|
|
$imagick->setImageCompression(Imagick::COMPRESSION_JPEG);
|
|
|
|
$imagick->setImageCompressionQuality($quality);
|
|
|
|
$imagick->cropThumbnailImage($width, $height);
|
|
|
|
$imagick->setImagePage(0, 0, 0, 0);
|
|
|
|
if (file_put_contents($thumb, $imagick) === false) {
|
|
|
|
log_error("Could not put contents.");
|
|
|
|
}
|
|
|
|
}catch(Exception $exception){
|
|
|
|
log_error($exception);
|
|
|
|
$imagick = file_get_contents($img);
|
2019-12-05 17:52:48 +00:00
|
|
|
}
|
2019-12-11 22:12:00 +00:00
|
|
|
|
|
|
|
header("Content-type: image/jpeg");
|
|
|
|
echo $imagick;
|
|
|
|
exit;
|
2019-12-05 17:52:48 +00:00
|
|
|
} else {
|
2019-12-11 22:12:00 +00:00
|
|
|
log_error("No valid image provided with {$img}.");
|
2019-12-05 17:52:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-12-05 13:11:18 +00:00
|
|
|
?>
|