Bolt\Twig\Handler\ImageHandler::imageInfo PHP Method

imageInfo() public method

Get an image.
public imageInfo ( string $fileName, string $safe ) : Bolt\Filesystem\Handler\ImageInterface
$fileName string
$safe string
return Bolt\Filesystem\Handler\ImageInterface
    public function imageInfo($fileName, $safe)
    {
        if ($fileName instanceof ImageInterface) {
            return $fileName;
        } elseif ($safe) {
            return null;
        }
        $image = $this->app['filesystem']->getFile('files://' . $fileName, new NullableImage());
        return $image;
    }

Usage Example

Beispiel #1
0
 public function testImageInfo()
 {
     $app = $this->getApp();
     $handler = new ImageHandler($app);
     $result = $handler->imageInfo('generic-logo.png', false);
     $this->assertSame(624, $result['width']);
     $this->assertSame(351, $result['height']);
     $this->assertSame('jpeg', $result['type']);
     $this->assertSame('image/jpeg', $result['mime']);
     $this->assertRegExp('#1.7777#', (string) $result['aspectratio']);
     $this->assertSame('generic-logo.png', $result['filename']);
     $this->assertRegExp('#tests/phpunit/web-root/files/generic-logo.png#', $result['fullpath']);
     $this->assertSame('/files/generic-logo.png', $result['url']);
     $this->assertSame('', $result['exif']['latitude']);
     $this->assertFalse($result['exif']['longitude']);
     $this->assertFalse($result['exif']['datetime']);
     $this->assertFalse($result['exif']['orientation']);
     $this->assertRegExp('#1.7777#', (string) $result['exif']['aspectratio']);
     $this->asserttrue($result['landscape']);
     $this->assertFalse($result['portrait']);
     $this->assertFalse($result['square']);
 }
All Usage Examples Of Bolt\Twig\Handler\ImageHandler::imageInfo