Image2Css\Converter::resize PHP Метод

resize() публичный Метод

public resize ( $width )
    public function resize($width)
    {
        $ratio = $width / $this->getImageWidth();
        $height = $this->getImageHeight() * $ratio;
        if ($this->getTrueColor() == true) {
            $new_image = imagecreatetruecolor($width, $height);
        } else {
            $new_image = imagecreate($width, $height);
        }
        imagealphablending($new_image, false);
        imagesavealpha($new_image, true);
        $transparent = imagecolorallocatealpha($new_image, 255, 255, 255, 127);
        imagefilledrectangle($new_image, 0, 0, $width, $height, $transparent);
        imagecopyresampled($new_image, $this->image, 0, 0, 0, 0, $width, $height, $this->getImageWidth(), $this->getImageHeight());
        $this->image = $new_image;
    }