Example usage : $Writer = new Writer(); $metadatas = new MetadataBag(); $metadata->add(new Metadata(new IPTC\ObjectName(), Value\Mono('Super title !'))); writes the metadatas to the file $Writer->writes('image.jpg', $metadatas); writes the metadatas to image_copied.jpg $Writer->writes('image.jpg', $metadatas, 'image_copied.jpg');
 /**
  * @covers MediaVorus\MediaCollection::match
  */
 public function testMatch()
 {
     $logger = new Logger('test');
     $logger->pushHandler(new NullHandler());
     $mediavorus = new MediaVorus(Reader::create($logger), Writer::create($logger), FFProbe::create());
     $collection = $mediavorus->inspectDirectory(__DIR__ . '/../../files/');
     $audio = $collection->match(new MediaType(MediaInterface::TYPE_AUDIO));
     $this->assertInstanceOf('\\Doctrine\\Common\\Collections\\ArrayCollection', $audio);
     $this->assertGreaterThan(0, $audio->count());
     foreach ($audio as $audio) {
         $this->assertEquals(MediaInterface::TYPE_AUDIO, $audio->getType());
     }
     $notAudio = $collection->match(new MediaType(MediaInterface::TYPE_AUDIO), true);
     $this->assertGreaterThan(0, $notAudio->count());
     $this->assertInstanceOf('\\Doctrine\\Common\\Collections\\ArrayCollection', $notAudio);
     foreach ($notAudio as $audio) {
         $this->assertFalse(MediaInterface::TYPE_AUDIO === $audio->getType());
     }
 }
Example #2
0
 /**
  * Instantiate mediavorus to register the mime types
  */
 public function setUp()
 {
     parent::setUp();
     $logger = new Logger('test');
     $logger->pushHandler(new NullHandler());
     $mediavorus = new MediaVorus(Reader::create($logger), Writer::create($logger), FFProbe::create());
 }
 public function setUp()
 {
     parent::setUp();
     $logger = new Logger('Tests');
     $logger->pushHandler(new NullHandler());
     $reader = Reader::create($logger);
     $writer = Writer::create($logger);
     $file = __DIR__ . '/../../../files/ExifTool.jpg';
     $this->object = new DefaultMedia(new File($file), $reader->reset()->files($file)->first(), $writer);
     $file = __DIR__ . '/../../../files/GPS.jpg';
     $this->GPSobject = new DefaultMedia(new File($file), $reader->reset()->files($file)->first(), $writer);
 }
Example #4
0
 public function setUp()
 {
     parent::setUp();
     $logger = new Logger('Tests');
     $logger->pushHandler(new NullHandler());
     $this->reader = Reader::create($logger);
     $this->writer = Writer::create($logger);
     $file = __DIR__ . '/../../../files/ExifTool.jpg';
     $this->object = new Image(new File($file), $this->reader->reset()->files($file)->first(), $this->writer);
     $logger = new Logger('test');
     $logger->pushHandler(new NullHandler());
     $this->ffprobe = FFProbe::create();
     $this->mediavorus = new MediaVorus($this->reader, $this->writer, $this->ffprobe);
 }
 /**
  * Generates a metadatas-free version of the file in the temporary directory
  *
  * @return string the path file to the temporary file
  */
 private function getTemporaryEmptyFile()
 {
     $tmpFile = tempnam(sys_get_temp_dir(), 'hash');
     unlink($tmpFile);
     try {
         $this->writer->reset();
         $this->writer->erase(true);
         $this->writer->write($this->file->getPathname(), new MetadataBag(), $tmpFile);
     } catch (PHPExiftoolExceptionInterface $e) {
         /**
          * Some files can not be written by exiftool
          */
         copy($this->file->getPathname(), $tmpFile);
     }
     $this->temporaryFiles[] = $tmpFile;
     return $tmpFile;
 }
Example #6
0
 public function process()
 {
     if (!$this->target) {
         $this->modx->log(1, 'target is empty');
         return false;
     }
     $logger = new Logger('exiftool');
     $Writer = Writer::create($logger);
     $bag = new MetadataBag();
     $this->modx->invokeEvent('OnModExifMetaTagAdd', array('writer' => &$this, 'metadataBag' => &$bag, 'tags' => $this->exif));
     $ok = $Writer->write($this->target, $bag);
     if (is_null($ok)) {
         $this->modx->log(1, 'Metadata bag is empty');
         return true;
     } elseif (!$ok) {
         return false;
     }
     return true;
 }
Example #7
0
 /**
  * Create MediaVorus
  *
  * @return MediaVorus
  */
 public static function create()
 {
     $logger = new Logger('MediaVorus');
     $logger->pushHandler(new NullHandler());
     return new static(Reader::create($logger), Writer::create($logger), FFProbe::create(array(), $logger));
 }
 public function getSyncCommandTester()
 {
     return parent::getSyncCommand();
 }