From 9036993e18c218e6da83a430cf9aee26a55f5b56 Mon Sep 17 00:00:00 2001 From: Christian Stocker Date: Wed, 6 Dec 2017 10:46:57 +0100 Subject: [PATCH] Added 2nd optional parameter to `Image::convertToAlternative` to provide your own options for loading the image as tiff. --- CHANGELOG.md | 4 ++++ lib/Imagine/Vips/Image.php | 16 ++++++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d7f06b2..bf14839 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # CHANGELOG +### 0.1.0 (2017-12-06) + + * Added 2nd optional parameter to `Image::convertToAlternative` to provide your own options for loading the image as tiff. + ### 0.0.5 (2017-12-03) * ext/vips 1.0.8 is required. Throw exceptions in methods, which needs vips 8.6. diff --git a/lib/Imagine/Vips/Image.php b/lib/Imagine/Vips/Image.php index 2c03033..d722905 100644 --- a/lib/Imagine/Vips/Image.php +++ b/lib/Imagine/Vips/Image.php @@ -702,11 +702,12 @@ public static function getColorArrayAlpha(ColorInterface $color, $bands = 4): ar } /** - * @param ImagineInterface|null $imagine the alternative imagine interface to use, autodetects, if not set + * @param ImagineInterface|null $imagine the alternative imagine interface to use, autodetects, if not set + * @param array|null $tiffOptions options to load the tiff image for conversion, eg ['strip' => true] * * @return ImageInterface */ - public function convertToAlternative(ImagineInterface $imagine = null) + public function convertToAlternative(ImagineInterface $imagine = null, array $tiffOptions = []) { if (null === $imagine) { if (class_exists('Imagick')) { @@ -716,7 +717,7 @@ public function convertToAlternative(ImagineInterface $imagine = null) } } - return $imagine->load($this->getImageStringForLoad($this->vips)); + return $imagine->load($this->getImageStringForLoad($this->vips, $tiffOptions)); } protected function applyProfile(ProfileInterface $profile, VipsImage $vips) @@ -784,13 +785,16 @@ protected function getDefaultProfileForInterpretation($vips) } /** - * @param VipsImage $res + * @param VipsImage $res + * @param array|null $tiffOptions options to load the tiff image for conversion, eg ['strip' => true] * * @return string */ - protected function getImageStringForLoad(VipsImage $res) + protected function getImageStringForLoad(VipsImage $res, $tiffOptions = []) { - return $res->tiffsave_buffer(['compression' => ForeignTiffCompression::NONE]); + $options = array_merge(['compression' => ForeignTiffCompression::NONE], $tiffOptions); + + return $res->tiffsave_buffer($options); } /**