/** * {@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; }
/** * Returns the image's info. * * @return Image\Info */ public function getInfo() { if (!$this->info) { $this->info = Image\Info::createFromString($this); } return $this->info; }
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; }
/** * @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}"); }
/** * {@inheritdoc} */ public function getImageInfo($path) { return Handler\Image\Info::createFromString($this->read($path)); }
/** * {@inheritdoc} */ public function getImageInfo($path) { $location = $this->applyPathPrefix($path); return Image\Info::createFromFile($location); }
/** * {@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)); }
/** * 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']); }
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()); }