Webiny\Component\Image\ImageLoader::load PHP Method

load() public static method

Create a new ImageInterface instance form the given binary string.
public static load ( string $string ) : mixed
$string string Binary string that holds image information.
return mixed
    public static function load($string)
    {
        return self::getLoader()->load($string);
    }

Usage Example

Example #1
0
 /**
  * Loads the image and returns an instance of Image class.
  *
  * @param string|File    $image             This can either be image file name that corresponds to File $key parameter,
  *                                          or it can be an instance of Webiny\Component\Storage\File\File.
  * @param string|Storage $storage           This can either be the name of the storage service or it can be an
  *                                          instance of Webiny\Component\Storage\Storage.
  *                                          NOTE: This parameter is not required if you pass the $image as
  *                                          instance of Webiny\Component\Storage\File\File.
  *
  * @return ImageInterface
  */
 public function image($image, $storage = 'local')
 {
     if ($image instanceof File) {
         return ImageLoader::load($image->getContents());
     } else {
         if (!$storage instanceof Storage) {
             $storage = ServiceManager::getInstance()->getService('Storage.' . $storage);
         }
         $file = new File($image, $storage);
         return ImageLoader::load($file->getContents());
     }
 }
All Usage Examples Of Webiny\Component\Image\ImageLoader::load