From 33a389fbe1c02843cbd181c554bfa0902ec08098 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Sun, 28 Oct 2012 13:53:55 +0100 Subject: [PATCH] new thumbnail style for galleries --- gallery/lib/thumbnail.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/gallery/lib/thumbnail.php b/gallery/lib/thumbnail.php index f92c5039e0..ed6652876f 100644 --- a/gallery/lib/thumbnail.php +++ b/gallery/lib/thumbnail.php @@ -81,12 +81,20 @@ public function create($albumPath, $square = false) { $images = \OC_Filecache::searchByMime('image', null, '/' . $user . '/files' . $albumPath); $count = min(count($images), 10); - $thumbnail = imagecreatetruecolor($count * 200, 200); + $thumbnail = imagecreatetruecolor(200, 200); + imagesavealpha($thumbnail, true); + imagefill($thumbnail, 0, 0, 0x7fff0000); + imagealphablending($thumbnail, true); for ($i = 0; $i < $count; $i++) { - $thumb = new Thumbnail($albumPath . '/' . $images[$i], true); + $thumb = new Thumbnail($albumPath . '/' . $images[$i]); $image = $thumb->get(); + $image->fitIn(80, 80); if ($image && $image->valid()) { - imagecopy($thumbnail, $image->resource(), $i * 200, 0, 0, 0, 200, 200); + $h = $image->height(); + $w = $image->width(); + $x = (($i % 2) * 100) + (100 - $w) / 2; + $y = (floor($i / 2) * 100) + (100 - $h) / 2; + imagecopy($thumbnail, $image->resource(), $x, $y, 0, 0, $w, $h); $image->destroy(); } }