public resizeToWidth ( integer $width, boolean $allow_enlarge = false ) : static | ||
$width | integer | |
$allow_enlarge | boolean | |
return | static |
public function resizeToWidth($width, $allow_enlarge = false)
{
$ratio = $width / $this->getSourceWidth();
$height = $this->getSourceHeight() * $ratio;
$this->resize($width, $height, $allow_enlarge);
return $this;
}
public function generateThumbnail($name) { $image = new ImageResize(self::PATH_ORIGINALS . DIRECTORY_SEPARATOR . $name); $image->resizeToWidth(1900); unlink(self::PATH_ORIGINALS . DIRECTORY_SEPARATOR . $name); $image->save(self::PATH_ORIGINALS . DIRECTORY_SEPARATOR . $name); $image = new ImageResize(self::PATH_ORIGINALS . DIRECTORY_SEPARATOR . $name); $image->resizeToWidth(200); $image->save(self::PATH_THUMBNAILS . DIRECTORY_SEPARATOR . $name); }