/** * @covers \MediaVorus\Media\Image::getWidth * @covers \MediaVorus\Media\Image::extractFromDimensions */ public function testGetWidth() { $this->assertTrue(is_int($this->object->getWidth())); $this->assertEquals(8, $this->object->getWidth()); $objects = $this->mediavorus->inspectDirectory(__DIR__ . '/../../../files/'); foreach ($objects as $object) { if ($object->getType() == MediaInterface::TYPE_IMAGE) { if (in_array($object->getFile()->getFilename(), array('KyoceraRaw.raw', 'Font.dfont', 'XMP.svg'))) { $this->assertNull($object->getWidth()); } else { $this->assertTrue(is_int($object->getWidth()), $object->getFile()->getFilename() . " has int width"); } } } }
/** * @VirtualProperty * * @return Integer */ public function getWidth() { $width = parent::getWidth(); if (null === $this->ffprobe) { return $width; } try { $video = $this->ffprobe->streams($this->file->getPathname())->videos()->first(); return $video->getDimensions()->getWidth(); } catch (FFMpegException $e) { } return $width; }
/** * @VirtualProperty * * @return Integer */ public function getWidth() { if (null !== ($result = parent::getWidth())) { return $result; } if (null === $this->ffprobe) { return null; } try { $video = $this->ffprobe->streams($this->file->getPathname())->videos()->first(); if ($video->has('width')) { return (int) $video->get('width'); } } catch (FFMpegException $e) { } return null; }