Image_GD::_do_crop PHP Method

_do_crop() protected method

Execute a crop.
protected _do_crop ( integer $width, integer $height, integer $offset_x, integer $offset_y ) : void
$width integer new width
$height integer new height
$offset_x integer offset from the left
$offset_y integer offset from the top
return void
    protected function _do_crop($width, $height, $offset_x, $offset_y)
    {
        // Create the temporary image to copy to
        $image = $this->_create($width, $height);
        // Loads image if not yet loaded
        $this->_load_image();
        // Execute the crop
        if (imagecopyresampled($image, $this->_image, 0, 0, $offset_x, $offset_y, $width, $height, $width, $height)) {
            // Swap the new image for the old one
            imagedestroy($this->_image);
            $this->_image = $image;
            // Reset the width and height
            $this->width = imagesx($image);
            $this->height = imagesy($image);
        }
    }