示例#1
0
 /**
  * {@inheritdoc}
  */
 public function getInfo($cache = true)
 {
     if (!$cache) {
         $this->info = null;
     }
     if (!$this->info) {
         try {
             $this->info = $this->filesystem->getImageInfo($this->path);
         } catch (IOException $e) {
             $this->info = Image\Info::createEmpty();
         }
     }
     return $this->info;
 }
示例#2
0
 /**
  * Returns the image's info.
  *
  * @return Image\Info
  */
 public function getInfo()
 {
     if (!$this->info) {
         $this->info = Image\Info::createFromString($this);
     }
     return $this->info;
 }
示例#3
0
 public static function castImageInfo(Image\Info $info, array $a, Stub $stub, $isNested, $filter = 0)
 {
     $a[Caster::PREFIX_VIRTUAL . 'width'] = $info->getWidth();
     $a[Caster::PREFIX_VIRTUAL . 'height'] = $info->getHeight();
     return $a;
 }
示例#4
0
 /**
  * @param Dimensions        $expected
  * @param Dimensions|string $actual
  */
 protected function assertDimensions(Dimensions $expected, $actual)
 {
     if (is_string($actual)) {
         $info = Image\Info::createFromString($actual);
         $actual = new Dimensions($info->getWidth(), $info->getHeight());
     }
     $this->assertEquals($expected, $actual, "Expected dimension {$expected} does not equal actual {$actual}");
 }
示例#5
0
 /**
  * {@inheritdoc}
  */
 public function getImageInfo($path)
 {
     return Handler\Image\Info::createFromString($this->read($path));
 }
示例#6
0
文件: Local.php 项目: bolt/filesystem
 /**
  * {@inheritdoc}
  */
 public function getImageInfo($path)
 {
     $location = $this->applyPathPrefix($path);
     return Image\Info::createFromFile($location);
 }
示例#7
0
 /**
  * {@inheritdoc}
  */
 public function getImageInfo($path)
 {
     $path = $this->normalizePath($path);
     $this->assertPresent($path);
     $adapter = $this->getAdapter();
     if ($adapter instanceof Capability\ImageInfo) {
         return $adapter->getImageInfo($path);
     }
     return Handler\Image\Info::createFromString($this->doRead($path));
 }
示例#8
0
 /**
  * Get image info from adapter.
  *
  * @param string $path
  *
  * @return Image\Info
  */
 private function doGetImageInfo($path)
 {
     // Get info from adapter if it's capable.
     $adapter = $this->getAdapter();
     if ($adapter instanceof Capability\ImageInfo) {
         return $adapter->getImageInfo($path);
     }
     // Else fallback to reading image contents and creating info from string.
     $result = $this->read($path);
     if ($result === false || !isset($result['contents'])) {
         throw new IOException('Failed to read file', $path);
     }
     return Image\Info::createFromString($result['contents']);
 }
示例#9
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());
 }