Skip to content

Commit c049b25

Browse files
committed
add thumbnail filter support
1 parent f625118 commit c049b25

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/ImageStack/ImageManipulator/ThumbnailRule/PatternThumbnailRule.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,13 @@ class PatternThumbnailRule implements ThumbnailRuleInterface, ImagineAwareInterf
4646
* formats examples:
4747
* - 300x200: try to fit in the 300x200 box without cropping
4848
* - <64: crop to fil in the 64x64 box
49+
* @param string $filter
50+
* @see \Imagine\Image\ImageInterface::FILTER_*
4951
*/
50-
public function __construct($pattern, $format) {
52+
public function __construct($pattern, $format, $filter = \Imagine\Image\ImageInterface::FILTER_UNDEFINED) {
5153
$this->pattern = $pattern;
5254
$this->format = $format;
55+
$this->filter = $filter;
5356
}
5457

5558
/**
@@ -108,7 +111,6 @@ protected function _thumbnailImage(ImageWithImagineInterface $image, ImagePathIn
108111

109112
/** @var IImage $animated */
110113
$animated = null;
111-
$options = null;
112114
$imagine = $image->getImagine();
113115
if ($this->handleAnimatedGif($image, function (IImage $iimage) use ($imagine, $size, &$animated, $image) {
114116
$animated = $imagine->create($size);
@@ -132,7 +134,7 @@ protected function _thumbnailImage(ImageWithImagineInterface $image, ImagePathIn
132134
// nothing
133135
return true;
134136
}
135-
$image->setImagineImage($image->getImagineImage()->thumbnail($size, $mode));
137+
$image->setImagineImage($image->getImagineImage()->thumbnail($size, $mode, $this->filter));
136138
return true;
137139
}
138140

src/ImageStack/ImagineAwareTrait.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ trait ImagineAwareTrait
2525
public function setImagine(ImagineInterface $imagine = null, array $imagineOptions = [])
2626
{
2727
$this->imagine = $imagine;
28+
$this->imagineOptions = $imagineOptions;
2829
}
2930

3031
/**

0 commit comments

Comments
 (0)