Esempio n. 1
0
 /**
  * {@inheritdoc}
  */
 public function getImageInfo($path)
 {
     // If cache doesn't support image info, just pass through to adapter.
     if (!$this->cache instanceof Capability\ImageInfo) {
         return $this->doGetImageInfo($path);
     }
     // Get from cache.
     $info = $this->cache->getImageInfo($path);
     if ($info !== false) {
         return is_array($info) ? Image\Info::createFromJson($info) : $info;
     }
     // Else from adapter.
     $info = $this->doGetImageInfo($path);
     // Save info from adapter.
     $object = ['path' => $path, 'image_info' => $info];
     $this->cache->updateObject($path, $object, true);
     return $info;
 }
Esempio n. 2
0
 public function testJsonSerialize()
 {
     $file = $this->filesystem->getFile('fixtures/images/1-top-left.jpg')->read();
     $expected = Image\Info::createFromString($file);
     $actual = Image\Info::createFromJson(json_decode(json_encode($expected), true));
     $this->assertEquals($expected->getDimensions(), $actual->getDimensions());
     $this->assertSame($expected->getType(), $actual->getType());
     $this->assertSame($expected->getBits(), $actual->getBits());
     $this->assertSame($expected->getChannels(), $actual->getChannels());
     $this->assertSame($expected->getMime(), $actual->getMime());
     $this->assertEquals($expected->getExif()->getData(), $actual->getExif()->getData());
 }