public function create($width, $height, $type = null)
    {
        if ( !is_numeric($width) ) {
            throw new \InvalidArgumentException('Image create failed, width must be numeric');
        }

        if ( !is_numeric($height) ) {
            throw new \InvalidArgumentException('Image create failed, height must be numeric');
        }

        $type = $this->getType($type);

        if ($type !== 'gif' && function_exists('imagecreatetruecolor'))
        {
            $newImage = imagecreatetruecolor($width, $height); // Unsupport gif file
        }
        else
        {
            $newImage = imagecreate($width, $height);
        }

        imagealphablending($newImage, true);

        $transparent = imagecolorallocatealpha($newImage, 255, 255, 255, 0);

        imagefilledrectangle($newImage, 0, 0, imagesx($newImage), imagesy($newImage), $transparent);
        imagefill($newImage, 0, 0, $transparent);

        imagesavealpha($newImage, true);

        $this->newImage = $newImage;

        return $this;
    }
public function create($width, $height, $type = null)
    {
        if ( !is_numeric($width) ) {
            throw new \InvalidArgumentException('Image create failed, width must be numeric');
        }

        if ( !is_numeric($height) ) {
            throw new \InvalidArgumentException('Image create failed, height must be numeric');
        }

        $type = $this->getType($type);

        if ($type !== 'gif' && function_exists('imagecreatetruecolor'))
        {
            $newImage = imagecreatetruecolor($width, $height); // Unsupport gif file
        }
        else
        {
            $newImage = imagecreate($width, $height);
        }

        imagealphablending($newImage, true);

        $transparent = imagecolorallocatealpha($newImage, 255, 255, 255, 0);

        imagefilledrectangle($newImage, 0, 0, imagesx($newImage), imagesy($newImage), $transparent);
        imagefill($newImage, 0, 0, $transparent);

        imagesavealpha($newImage, true);

        $this->newImage = $newImage;

        return $this;
    }
public function create ( $ width , $ height , $ type = null ) { if ( ! is_numeric ( $ width ) ) { throw new \ InvalidArgumentException ( 'Image create failed, width must be numeric' ) ; } if ( ! is_numeric ( $ height ) ) { throw new \ InvalidArgumentException ( 'Image create failed, height must be numeric' ) ; } $ type = $ this -> getType ( $ type ) ; if ( $ type !== 'gif' && function_exists ( 'imagecreatetruecolor' ) ) { $ newImage = imagecreatetruecolor ( $ width , $ height ) ; // Unsupport gif file
 } else { $ newImage = imagecreate ( $ width , $ height ) ; } imagealphablending ( $ newImage , true ) ; $ transparent = imagecolorallocatealpha ( $ newImage , 255 , 255 , 255 , 0 ) ; imagefilledrectangle ( $ newImage , 0 , 0 , imagesx ( $ newImage ) , imagesy ( $ newImage ) , $ transparent ) ; imagefill ( $ newImage , 0 , 0 , $ transparent ) ; imagesavealpha ( $ newImage , true ) ; $ this -> newImage = $ newImage ; return $ this ; }
Create new canvas image
@param int $width
@param int $height
@param string $type null
@return $this
Create new canvas image