Sulu\Bundle\MediaBundle\Media\ImageConverter\Scaler\ScalerInterface::scale PHP Method

scale() public method

Scales an image according to the given parameters.
public scale ( Imagine\Image\ImageInterface $image, integer $x, integer $y, string $mode = ImageInterface::THUMBNAIL_OUTBOUND, boolean $forceRatio = true, boolean $retina = false ) : Imagine\Image\ImageInterface
$image Imagine\Image\ImageInterface The image to scale
$x integer The value for the x dimension
$y integer The value for the y dimension
$mode string The mode to use for scale, inset or outbound
$forceRatio boolean Whether or not to force the format ratio when using the outbound mode
$retina boolean Whether or not the scale is applied to a retina image
return Imagine\Image\ImageInterface The scaled image
    public function scale(ImageInterface $image, $x, $y, $mode = ImageInterface::THUMBNAIL_OUTBOUND, $forceRatio = true, $retina = false);

Usage Example

Example #1
0
 /**
  * Scales a given image according to the information passed as the second argument.
  *
  * @param ImageInterface $image
  * @param $scale
  *
  * @return ImageInterface
  */
 private function applyScale(ImageInterface $image, $scale)
 {
     return $this->modifyAllLayers($image, function (ImageInterface $layer) use($scale) {
         return $this->scaler->scale($layer, $scale['x'], $scale['y'], $scale['mode'], $scale['forceRatio'], $scale['retina']);
     });
 }
ScalerInterface