open() public static method

Creates a new ImageInterface instance from the given image at the provided path.
public static open ( File $image ) : Webiny\Component\Image\ImageInterface
$image Webiny\Component\Storage\File\File Path to an image on the disk.
return Webiny\Component\Image\ImageInterface
Example #1
0
 public function testOpen()
 {
     // build File mock
     $file = $this->getMockBuilder('\\Webiny\\Component\\Storage\\File\\File')->disableOriginalConstructor()->setMethods(['getAbsolutePath', 'getKey'])->getMock();
     // getAbsolutePath mock
     $file->expects($this->any())->method('getAbsolutePath')->will($this->returnValue(__DIR__ . '/image.gif'));
     // getKey mock
     $file->expects($this->once())->method('getKey')->will($this->returnValue(__DIR__ . '/image.gif'));
     $image = ImageLoader::open($file);
     $this->assertInstanceOf('\\Webiny\\Component\\Image\\ImageInterface', $image);
 }
Example #2
0
 public function provideImage()
 {
     Image::setConfig(realpath(__DIR__ . '/../../' . self::CONFIG));
     // build File mock
     $file = $this->getMockBuilder('\\Webiny\\Component\\Storage\\File\\File')->disableOriginalConstructor()->setMethods(['getAbsolutePath', 'getKey'])->getMock();
     // getAbsolutePath mock
     $file->expects($this->any())->method('getAbsolutePath')->will($this->returnValue(__DIR__ . '/../../image.gif'));
     // getKey mock
     $file->expects($this->once())->method('getKey')->will($this->returnValue(__DIR__ . '/../../image.gif'));
     $image = ImageLoader::open($file);
     return [[$image]];
 }