resize() public static method

Resize or crop an image and replace the original with the resized version
Deprecation: Deprecated since Contao 4.3, to be removed in Contao 5.0. Use the contao.image.image_factory service instead.
public static resize ( string $image, integer $width, integer $height, string $mode = '' ) : boolean
$image string The image path
$width integer The target width
$height integer The target height
$mode string The resize mode
return boolean True if the image could be resized successfully
Exemplo n.º 1
0
 /**
  * Resize the file if it is an image
  *
  * @param integer $width  The target width
  * @param integer $height The target height
  * @param string  $mode   The resize mode
  *
  * @return boolean True if the image could be resized successfully
  */
 public function resizeTo($width, $height, $mode = '')
 {
     if (!$this->isImage) {
         return false;
     }
     $return = \Image::resize($this->strFile, $width, $height, $mode);
     if ($return) {
         $this->arrPathinfo = array();
         $this->arrImageSize = array();
     }
     return $return;
 }
Exemplo n.º 2
0
 /**
  * Tests the legacy resize() method.
  *
  * @param array $arguments
  * @param array $expectedResult
  *
  * @dataProvider getLegacyResize
  */
 public function testLegacyResize($arguments, $expectedResult)
 {
     $result = Image::resize($arguments[0], $arguments[1], $arguments[2], $arguments[3]);
     $this->assertSame($result, $expectedResult);
 }
Exemplo n.º 3
0
 /**
  * Resize an image and crop it if necessary
  *
  * @param string  $image  The image path
  * @param integer $width  The target width
  * @param integer $height The target height
  * @param string  $mode   An optional resize mode
  *
  * @return boolean True if the image has been resized correctly
  *
  * @deprecated Deprecated since Contao 4.0, to be removed in Contao 5.0.
  *             Use Image::resize() instead.
  */
 protected function resizeImage($image, $width, $height, $mode = '')
 {
     trigger_error('Using Controller::resizeImage() has been deprecated and will no longer work in Contao 5.0. Use Image::resize() instead.', E_USER_DEPRECATED);
     return \Image::resize($image, $width, $height, $mode);
 }