thumbnail.php generate thumbnails on demand
This commit is contained in:
parent
d0458cd23b
commit
d321093d0f
2 changed files with 27 additions and 1 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -4,6 +4,8 @@ Homestead.json
|
||||||
Homestead.yaml
|
Homestead.yaml
|
||||||
.env
|
.env
|
||||||
/public/docs
|
/public/docs
|
||||||
|
/public/staticimages
|
||||||
|
/public/thumbnails
|
||||||
/resources/docs
|
/resources/docs
|
||||||
|
|
||||||
composer.lock
|
composer.lock
|
||||||
|
|
|
@ -1,3 +1,27 @@
|
||||||
<?php
|
<?php
|
||||||
echo "TODO: create thumbnail for ".$_GET["id"]." here";
|
|
||||||
|
#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}.");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
Loading…
Reference in a new issue