From e4b3ee8d8f93262423eaaeee390deb6e680bb1e3 Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Sat, 13 Jan 2018 00:34:28 +0100 Subject: Fix float/integer handling in image API * IImage::crop/preciseResize now have type hinting for integers * found while testing strict typing for PHP 7+ Signed-off-by: Morris Jobke --- lib/private/Preview/Generator.php | 4 ++-- lib/private/Preview/GeneratorHelper.php | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'lib/private/Preview') diff --git a/lib/private/Preview/Generator.php b/lib/private/Preview/Generator.php index 448a7a57580..60b7536d074 100644 --- a/lib/private/Preview/Generator.php +++ b/lib/private/Preview/Generator.php @@ -345,9 +345,9 @@ class Generator { $scaleH = $maxHeight / $widthR; $scaleW = $width; } - $preview->preciseResize(round($scaleW), round($scaleH)); + $preview->preciseResize((int)round($scaleW), (int)round($scaleH)); } - $cropX = floor(abs($width - $preview->width()) * 0.5); + $cropX = (int)floor(abs($width - $preview->width()) * 0.5); $cropY = 0; $preview->crop($cropX, $cropY, $width, $height); } else { diff --git a/lib/private/Preview/GeneratorHelper.php b/lib/private/Preview/GeneratorHelper.php index 6535fde058b..587f8174b02 100644 --- a/lib/private/Preview/GeneratorHelper.php +++ b/lib/private/Preview/GeneratorHelper.php @@ -27,7 +27,7 @@ use OCP\Files\File; use OCP\Files\IRootFolder; use OCP\Files\SimpleFS\ISimpleFile; use OCP\IImage; -use OCP\Image as img; +use OCP\Image as OCPImage; use OCP\Preview\IProvider; /** @@ -79,7 +79,9 @@ class GeneratorHelper { * @return IImage */ public function getImage(ISimpleFile $maxPreview) { - return new img($maxPreview->getContent()); + $image = new OCPImage(); + $image->loadFromData($maxPreview->getContent()); + return $image; } /** -- cgit v1.2.3