/** * @covers PHPExiftool\Reader::resetResults */ public function testResetFilters() { $file = self::$tmpDir . '/test.jpg'; $this->object->files($file)->all(); $file = self::$tmpDir . '/test2.jpg'; $this->object->files($file)->all(); $this->assertEquals(2, count($this->object->all())); }
/** * @covers PHPExiftool\Reader::resetResults */ public function testResetFilters() { $file = self::$tmpDir . '/hello.exiftool'; $this->object->files($file)->all(); $file = self::$tmpDir . '/hello.world'; $this->object->files($file)->all(); $this->assertEquals(2, count($this->object->all())); }
/** * {@inheritdoc} */ public function extract($filename, Specification $targetFormat) { if (!file_exists($filename)) { return null; } $metadatas = $this->reader->files($filename)->first(); $imageFilename = $this->tempDir . '/' . uniqid() . '.jpg'; foreach ($metadatas->getMetadatas() as $metadata) { if ($metadata->getTag()->getName() !== 'Picture' && ValueInterface::TYPE_BINARY !== $metadata->getValue()->getType()) { continue; } $filesystem = new Filesystem(); if (!$filesystem->exists($this->tempDir)) { $filesystem->mkdir($this->tempDir); } $content = (string) $metadata->getValue()->asString(); $filesystem->dumpFile($imageFilename, $content); return $imageFilename; } return null; }
/** * @covers PHPExiftool\Writer::write */ public function testWriteInPlaceErased() { $metadatas = new Driver\Metadata\MetadataBag(); $metadatas->add(new Driver\Metadata\Metadata(new Driver\Tag\IPTC\ObjectName(), new Driver\Value\Mono('Beautiful Object'))); $metadatas->add(new Driver\Metadata\Metadata(new Driver\Tag\IPTC\ObjectName(), new Driver\Value\Mono('Beautiful Object'))); $metadatas->add(new Driver\Metadata\Metadata(new Driver\Tag\XMPIptcExt\PersonInImage(), new Driver\Value\Multi(array('Romain', 'Nicolas')))); $this->object->erase(true); $changedFiles = $this->object->write($this->inPlace, $metadatas); $this->assertEquals(1, $changedFiles); $reader = new Reader($this->getExiftool(), new RDFParser()); $metadatasRead = $reader->files($this->inPlace)->first()->getMetadatas(); $this->assertLessThan(50, count($metadatasRead)); $this->assertEquals('Beautiful Object', $metadatasRead->get('IPTC:ObjectName')->getValue()->asString()); $this->assertEquals(array('Romain', 'Nicolas'), $metadatasRead->get('XMP-iptcExt:PersonInImage')->getValue()->asArray()); }