code: public static function fromFile(File $file)
  	{
  		$extension = strtolower($file->extension);
  		$function = null;
  
  		if ($extension === 'jpg')
  		{
  			$extension = 'jpeg';
  		}
  
  		if (\in_array($extension, array('gif', 'jpeg', 'png')))
  		{
  			$function = 'imagecreatefrom' . $extension;
  		}
  
  		if ($function === null || !\is_callable($function))
  		{
  			throw new \InvalidArgumentException('Image type "' . $file->extension . '" cannot be processed by GD');
  		}
  
  		$image = $function(System::getContainer()->getParameter('kernel.project_dir') . '/' . $file->path);
  
  		if ($image === false)
  		{
  			throw new \RuntimeException('Image "' . $file->path . '" failed to be processed by GD');
  		}
  
  		return new static($image);
  	}
docs: Get the GD image object from an image file
  
  @param File $file The file object
  
  @return static The GD image object
  
  @throws \InvalidArgumentException If the image type cannot be processed
  @throws \RuntimeException         If the image failed to be processed