c3lf-system-3/public/thumbnail.php

27 lines
716 B
PHP

<?php
#echo "TODO: create thumbnail for ".$_GET["id"]." here";
$width = 100;
$height = 100;
$quality = 90;
$thumb = getcwd() . $_GET["id"];
$img = str_replace("thumbnails", "staticimages", $thumb);
if (is_file($img)) {
$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) {
throw new Exception("Could not put contents.");
}
return true;
} else {
throw new Exception("No valid image provided with {$img}.");
}
?>