src/classes/CCImage.php
public static function create( $file, $type = null ) 
	{
		// when no type is given use the file extension
		if ( is_null( $type ) ) 
		{
			$type = CCStr::extension( $file );

			// validate type
			if ( !in_array( $type, static::$available_image_types ) )
			{
				$type = null;
			}
		}

		$image_data = getimagesize( $file );

		if ( $image_data === false ) 
		{
			return false;
		}

		$image = null;

		switch( $image_data['mime'] ) 
		{
			case 'image/gif':
				$image = imagecreatefromgif( $file );
			break;

			case 'image/jpeg';
				$image = imagecreatefromjpeg( $file );
			break;

			case 'image/png':
				$image = imagecreatefrompng( $file );
			break;

			default:
				// we dont support other image types
				return false;
			break;
		}

		// when the image type is still null we are going to use 
		// the mime type of the image 
		if ( is_null( $type ) )
		{
			$type = CCStr::suffix( $image_data['mime'], '/' );
		}

		return new static( $image, $type );
	}
public static function create( $file, $type = null ) 
	{
		// when no type is given use the file extension
		if ( is_null( $type ) ) 
		{
			$type = CCStr::extension( $file );

			// validate type
			if ( !in_array( $type, static::$available_image_types ) )
			{
				$type = null;
			}
		}

		$image_data = getimagesize( $file );

		if ( $image_data === false ) 
		{
			return false;
		}

		$image = null;

		switch( $image_data['mime'] ) 
		{
			case 'image/gif':
				$image = imagecreatefromgif( $file );
			break;

			case 'image/jpeg';
				$image = imagecreatefromjpeg( $file );
			break;

			case 'image/png':
				$image = imagecreatefrompng( $file );
			break;

			default:
				// we dont support other image types
				return false;
			break;
		}

		// when the image type is still null we are going to use 
		// the mime type of the image 
		if ( is_null( $type ) )
		{
			$type = CCStr::suffix( $image_data['mime'], '/' );
		}

		return new static( $image, $type );
	}
public static function create ( $ file , $ type = null ) { // when no type is given use the file extension if ( is_null ( $ type ) ) { $ type = CCStr :: extension ( $ file ) ; // validate type if ( ! in_array ( $ type , static :: $ available_image_types ) ) { $ type = null ; } } $ image_data = getimagesize ( $ file ) ; if ( $ image_data === false ) { return false ; } $ image = null ; switch ( $ image_data [ 'mime' ] ) { case 'image/gif' : $ image = imagecreatefromgif ( $ file ) ; break ; case 'image/jpeg' ; $ image = imagecreatefromjpeg ( $ file ) ; break ; case 'image/png' : $ image = imagecreatefrompng ( $ file ) ; break ; default : // we dont support other image types return false ; break ; } // when the image type is still null we are going to use  // the mime type of the image  if ( is_null ( $ type ) ) { $ type = CCStr :: suffix ( $ image_data [ 'mime' ] , '/' ) ; } return new static ( $ image , $ type ) ; }
Create a image from file

@param string 	$file
@param string 	$type		jpg|png|gif

@return CCImage|false
Create a image from file