1<?php 2 3/* 4 * This file is part of the Imagine package. 5 * 6 * (c) Bulat Shakirzyanov <mallluhuct@gmail.com> 7 * 8 * For the full copyright and license information, please view the LICENSE 9 * file that was distributed with this source code. 10 */ 11 12namespace Imagine\Filter\Basic; 13 14use Imagine\Filter\FilterInterface; 15use Imagine\Image\ImageInterface; 16use Imagine\Image\BoxInterface; 17 18/** 19 * A resize filter 20 */ 21class Resize implements FilterInterface 22{ 23 /** 24 * @var BoxInterface 25 */ 26 private $size; 27 private $filter; 28 29 /** 30 * Constructs Resize filter with given width and height 31 * 32 * @param BoxInterface $size 33 * @param string $filter 34 */ 35 public function __construct(BoxInterface $size, $filter = ImageInterface::FILTER_UNDEFINED) 36 { 37 $this->size = $size; 38 $this->filter = $filter; 39 } 40 41 /** 42 * {@inheritdoc} 43 */ 44 public function apply(ImageInterface $image) 45 { 46 return $image->resize($this->size, $this->filter); 47 } 48} 49