PHPExiftool\PreviewExtractor::extract PHP Method

extract() public method

public extract ( $pathfile, $outputDir )
    public function extract($pathfile, $outputDir)
    {
        if (!file_exists($pathfile)) {
            throw new LogicException(sprintf('%s does not exists', $pathfile));
        }
        if (!is_dir($outputDir) || !is_writable($outputDir)) {
            throw new LogicException(sprintf('%s is not writable', $outputDir));
        }
        $command = "-if " . escapeshellarg('$photoshopthumbnail') . " -b -PhotoshopThumbnail " . "-w " . escapeshellarg(realpath($outputDir) . '/PhotoshopThumbnail%c.jpg') . " -execute " . "-if " . escapeshellarg('$jpgfromraw') . " -b -jpgfromraw " . "-w " . escapeshellarg(realpath($outputDir) . '/JpgFromRaw%c.jpg') . " -execute " . "-if " . escapeshellarg('$previewimage') . " -b -previewimage " . "-w " . escapeshellarg(realpath($outputDir) . '/PreviewImage%c.jpg') . " " . "-common_args -q -m " . $pathfile;
        try {
            $this->exiftool->executeCommand($command);
        } catch (RuntimeException $e) {
        }
        return new \DirectoryIterator($outputDir);
    }

Usage Example

 /**
  * @expectedException \PHPExiftool\Exception\LogicException
  */
 public function testExtractWrongDir()
 {
     $extractor = new PreviewExtractor($this->getExiftool());
     $tmpDir = sys_get_temp_dir() . '/tests' . mt_rand(10000, 99999);
     $extractor->extract(__DIR__ . '/../../../files/ExifTool.jpg', $tmpDir);
 }
PreviewExtractor