load() публичный статический Метод

Create a new ImageInterface instance form the given binary string.
public static load ( string $string ) : mixed
$string string Binary string that holds image information.
Результат mixed
Пример #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());
     }
 }
Пример #2
0
 public function testLoad()
 {
     $image = ImageLoader::load(base64_decode('R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7'));
     $this->assertInstanceOf('\\Webiny\\Component\\Image\\ImageInterface', $image);
 }