我创建了一个继承 LoaderInterface 的新类。我的目标是应用水印,然后将图像调整为缩略图......有人知道怎么做吗?问题是我的类返回加载一个过滤器类型并且不能返回超过1个过滤器类型......那么如何创建一个链?
非常感谢。
这是我的示例代码
namespace Avalanche\Bundle\ImagineBundle\Imagine\Filter\Loader;
use Imagine\Image\Box;
use Imagine\Image\ManipulatorInterface;
use Imagine\Filter\Basic\Thumbnail;
use \Imagine\Filter\Basic\Paste;
class ThumbnailWatermarkFilterLoader implements LoaderInterface
{
const WATERMARK_IMAGE_PATH = "watermark_image";
const WATERMARK_FONT_PATH = "font";
public function load(array $options = array())
{
$mode = $options['mode'] === 'inset' ?
ManipulatorInterface::THUMBNAIL_INSET :
ManipulatorInterface::THUMBNAIL_OUTBOUND;
list($width, $height) = $options['size'];
$watermark = new \Imagine\Gd\Image(imagecreatefrompng($options[self::WATERMARK_IMAGE_PATH]));
$point = new \Imagine\Image\Point($width / 2 , $height /2);
$thumb = new Paste($watermark, $point);
return $thumb;
}
}