Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/gallery.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier Paroz <github@oparoz.com>2015-09-27 01:55:16 +0300
committerOlivier Paroz <github@oparoz.com>2015-09-27 01:55:16 +0300
commitc65fde0d26c537fded10d55950a668427a6532f3 (patch)
treed8fe5cdffcca0d84aa5495acf7a29f3d146b4d55
parentd4e8f682ea961e63d8e0bca66988a294b4fc7f15 (diff)
Don't delete the patches on 8.0v14.1-stable8
-rw-r--r--patches/bitmap-max-preview.pull.13635.patch132
1 files changed, 132 insertions, 0 deletions
diff --git a/patches/bitmap-max-preview.pull.13635.patch b/patches/bitmap-max-preview.pull.13635.patch
new file mode 100644
index 00000000..760dd0f6
--- /dev/null
+++ b/patches/bitmap-max-preview.pull.13635.patch
@@ -0,0 +1,132 @@
+From 4bf9150f5d360953abd28b73d12d079c32cfd51c Mon Sep 17 00:00:00 2001
+From: Olivier Paroz <github@oparoz.com>
+Date: Wed, 11 Mar 2015 17:35:33 +0100
+Subject: [PATCH] The bitmap preview class now takes maxX and maxY into
+ consideration
+
+This is a fix for owncloud#13607
+and is part of the global programme: owncloud#13609
+
+I originally filled the whole area with a transparent background, but
+this creates resizing issues as it doesn't reflect the proper image
+ratio.
+---
+ lib/private/preview/bitmap.php | 82 +++++++++++++++++++++++++++++++++++++-----
+ 1 file changed, 74 insertions(+), 8 deletions(-)
+
+diff --git a/lib/private/preview/bitmap.php b/lib/private/preview/bitmap.php
+index 25f65cf..9171228 100644
+--- a/lib/private/preview/bitmap.php
++++ b/lib/private/preview/bitmap.php
+@@ -1,6 +1,8 @@
+ <?php
+ /**
+ * Copyright (c) 2013-2014 Georg Ehrke georg@ownCloud.com
++ * Copyright (c) 2014-2015 Olivier Paroz <owncloud@interfasys.ch>
++ *
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+@@ -8,30 +10,94 @@
+
+ namespace OC\Preview;
+
++use Imagick;
++
++/**
++ * Creates a PNG preview using ImageMagick via the PECL extension
++ *
++ * @package OC\Preview
++ */
+ abstract class Bitmap extends Provider {
++
++ /**
++ * @type array
++ */
++ private $maxDims;
++
+ /**
+ * {@inheritDoc}
+ */
+ public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) {
++ $this->maxDims = [$maxX, $maxY];
++
+ $tmpPath = $fileview->toTmpFile($path);
++ if (!$tmpPath) {
++ return false;
++ }
+
+- //create imagick object from bitmap or vector file
++ // Creates \Imagick object from bitmap or vector file
+ try {
+- // Layer 0 contains either the bitmap or
+- // a flat representation of all vector layers
+- $bp = new \Imagick($tmpPath . '[0]');
+-
+- $bp->setImageFormat('png');
++ $bp = $this->getResizedPreview($tmpPath);
+ } catch (\Exception $e) {
+- \OC_Log::write('core', $e->getmessage(), \OC_Log::ERROR);
++ \OC_Log::write('core', 'ImageMagick says: ' . $e->getmessage(), \OC_Log::ERROR);
+ return false;
+ }
+
+ unlink($tmpPath);
+
+ //new bitmap image object
+- $image = new \OC_Image($bp);
++ $image = new \OC_Image();
++ $image->loadFromData($bp);
+ //check if image object is valid
+ return $image->valid() ? $image : false;
+ }
++
++ /**
++ * Returns a preview of maxX times maxY dimensions in PNG format
++ *
++ * * The default resolution is already 72dpi, no need to change it for a bitmap output
++ * * It's possible to have proper colour conversion using profileimage().
++ * ICC profiles are here: http://www.color.org/srgbprofiles.xalter
++ * * It's possible to Gamma-correct an image via gammaImage()
++ *
++ * @param string $tmpPath the location of the file to convert
++ *
++ * @return \Imagick
++ */
++ private function getResizedPreview($tmpPath) {
++ $bp = new Imagick();
++
++ // Layer 0 contains either the bitmap or a flat representation of all vector layers
++ $bp->readImage($tmpPath . '[0]');
++
++ $bp = $this->resize($bp);
++
++ $bp->setImageFormat('png');
++
++ return $bp;
++ }
++
++ /**
++ * Returns a resized \Imagick object
++ *
++ * If you want to know more on the various methods available to resize an
++ * image, check out this link : @link https://stackoverflow.com/questions/8517304/what-the-difference-of-sample-resample-scale-resize-adaptive-resize-thumbnail-im
++ *
++ * @param \Imagick $bp
++ *
++ * @return \Imagick
++ */
++ private function resize($bp) {
++ list($maxX, $maxY) = $this->maxDims;
++ list($previewWidth, $previewHeight) = array_values($bp->getImageGeometry());
++
++ // We only need to resize a preview which doesn't fit in the maximum dimensions
++ if ($previewWidth > $maxX || $previewHeight > $maxY) {
++ // TODO: LANCZOS is the default filter, CATROM could bring similar results faster
++ $bp->resizeImage($maxX, $maxY, imagick::FILTER_LANCZOS, 1, true);
++ }
++
++ return $bp;
++ }
++
+ }