コード例 #1
0
 /**
  * {@inheritDoc}
  *
  * @return AssetInterface|ImageInterface
  */
 public function apply(ImageInterface $image)
 {
     $asset = new StringAsset($image->get('png'));
     $asset->load();
     try {
         $this->filter->filterDump($asset);
     } catch (FilterException $e) {
         // FilterException is thrown when "optipng" utility was not found.
         // This should never happen on production environment; maybe we should enforce it?
     }
     // TODO: workaround hackish way of applying optipng and other compression filters.
     // Without that we're loosing some optimizations by running content through image library functions!
     return new ImageAssetWrapper($asset);
     //        return $this->imagine->load($asset->getContent());
 }