write() public method

Writes metadatas to the file. If a destination is provided, original file is not modified.
public write ( string $file, MetadataBag $metadatas, string $destination = null ) : integer
$file string The input file
$metadatas PHPExiftool\Driver\Metadata\MetadataBag A bag of metadatas
$destination string The output file
return integer the number of file written
コード例 #1
0
 /**
  * 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;
 }
コード例 #2
0
 /**
  * @covers PHPExiftool\Writer::write
  * @covers PHPExiftool\Exception\InvalidArgumentException
  * @expectedException PHPExiftool\Exception\InvalidArgumentException
  */
 public function testWriteFail()
 {
     $this->object->write('ici', new Driver\Metadata\MetadataBag());
 }