/** * Resizes image to fit into a square container * * Manual: http://code.google.com/p/zend-image/wiki/Quick_Start * * @param int $imagePath Original image path * @param int $newPath Transformed image path * @param int $fitInDimension Container size (square) the transformed image should fit in * @return boolean True on save success, false on failure */ public static function resizeImage($imagePath, $newPath, $fitInDimensionX, $fitInDimensionY = 0) { if (substr($imagePath, 0, 1) != '/') { $imagePath = '/' . $imagePath; } if (substr($newPath, 0, 1) != '/') { $newPath = '/' . $newPath; } if ($fitInDimensionY == 0) { $fitInDimensionY = $fitInDimensionX; } $img = new Zend_Image(Admin_View_Helper_ImageControls::_getPublicPath() . $imagePath, new Zend_Image_Driver_Gd()); $transformed = new Zend_Image_Transform($img); $resized = $transformed->fitIn($fitInDimensionX, $fitInDimensionY); $resized->save(Admin_View_Helper_ImageControls::_getPublicPath() . $newPath); return file_exists(Admin_View_Helper_ImageControls::_getPublicPath() . $newPath); }
public function testCanResize() { $zendImage = new Zend_Image_Transform(dirname(__FILE__) . '/' . $this->_file300x431, new Zend_Image_Driver_Gd()); $this->assertEquals(md5($zendImage->resize(150, 150)->getBinary()), md5_file(dirname(__FILE__) . '/' . $this->_file150x150)); }
public function testCanResize() { $this->_driverMock->expects($this->once())->method('resize')->with(100, 50); $transform = new Zend_Image_Transform('doesnt-matter.jpg', $this->_driverMock); $transform->resize(100, 50); }