Permalink
Browse files

Add filter argument to thumbnail method

  • Loading branch information...
1 parent 284408f commit b991c3407c02247650a662a7828c5388dddcebf4 @romainneutron romainneutron committed Aug 27, 2013
View
@@ -8,6 +8,7 @@
colors.
* Add support for ICC profiles
* Add support for CMYK and grayscale colorspace images.
+ * Add filter argument to ImageInterface::thumbnail method.
### 0.5.0 (2013-07-10)
@@ -31,22 +31,28 @@ class Thumbnail implements FilterInterface
private $mode;
/**
+ * @var string
+ */
+ private $filter;
+
+ /**
* Constructs the Thumbnail filter with given width, height and mode
*
* @param BoxInterface $size
* @param string $mode
*/
- public function __construct(BoxInterface $size, $mode = ImageInterface::THUMBNAIL_INSET)
+ public function __construct(BoxInterface $size, $mode = ImageInterface::THUMBNAIL_INSET, $filter = ImageInterface::FILTER_UNDEFINED)
{
$this->size = $size;
$this->mode = $mode;
+ $this->filter = $filter;
}
/**
* {@inheritdoc}
*/
public function apply(ImageInterface $image)
{
- return $image->thumbnail($this->size, $this->mode);
+ return $image->thumbnail($this->size, $this->mode, $this->filter);
}
}
@@ -196,9 +196,9 @@ public function show($format, array $options = array())
/**
* {@inheritdoc}
*/
- public function thumbnail(BoxInterface $size, $mode = ImageInterface::THUMBNAIL_INSET)
+ public function thumbnail(BoxInterface $size, $mode = ImageInterface::THUMBNAIL_INSET, $filter = ImageInterface::FILTER_UNDEFINED)
{
- return $this->add(new Thumbnail($size, $mode));
+ return $this->add(new Thumbnail($size, $mode, $filter));
}
/**
@@ -18,7 +18,7 @@
/**
* {@inheritdoc}
*/
- public function thumbnail(BoxInterface $size, $mode = ImageInterface::THUMBNAIL_INSET)
+ public function thumbnail(BoxInterface $size, $mode = ImageInterface::THUMBNAIL_INSET, $filter = ImageInterface::FILTER_UNDEFINED)
{
if ($mode !== ImageInterface::THUMBNAIL_INSET &&
$mode !== ImageInterface::THUMBNAIL_OUTBOUND) {
@@ -55,7 +55,7 @@ public function thumbnail(BoxInterface $size, $mode = ImageInterface::THUMBNAIL_
);
} else {
$imageSize = $thumbnail->getSize()->scale($ratio);
- $thumbnail->resize($imageSize);
+ $thumbnail->resize($imageSize, $filter);
}
$thumbnail->crop(new Point(
max(0, round(($imageSize->getWidth() - $size->getWidth()) / 2)),
@@ -64,10 +64,10 @@ public function thumbnail(BoxInterface $size, $mode = ImageInterface::THUMBNAIL_
} else {
if (!$imageSize->contains($size)) {
$imageSize = $imageSize->scale($ratio);
- $thumbnail->resize($imageSize);
+ $thumbnail->resize($imageSize, $filter);
} else {
$imageSize = $thumbnail->getSize()->scale($ratio);
- $thumbnail->resize($imageSize);
+ $thumbnail->resize($imageSize, $filter);
}
}
@@ -153,12 +153,13 @@ public function strip();
*
* @param BoxInterface $size
* @param string $mode
+ * @param string $filter The filter to use for resizing, one of ImageInterface::FILTER_*
*
* @throws RuntimeException
*
* @return ManipulatorInterface
*/
- public function thumbnail(BoxInterface $size, $mode = self::THUMBNAIL_INSET);
+ public function thumbnail(BoxInterface $size, $mode = self::THUMBNAIL_INSET, $filter = ImageInterface::FILTER_UNDEFINED);
/**
* Applies a given mask to current image's alpha channel

0 comments on commit b991c34

Please sign in to comment.