is_raw_image()) throw new Exception('Provided file is not raw image datas'); $tmpFiles = array(); $cmd = $this->binary; $thisFile = $tmpFiles[] = $this->registry->get('GV_RootPath') . 'tmp/' . time() . '-PI'; $cmd .= sprintf(' -b -PreviewImage %s > %s' , $this->escapeshellargs($raw_datas->getPathname()) , $this->escapeshellargs($thisFile) ); $this->shell_cmd($cmd); $cmd = $this->binary; $thisFile = $tmpFiles[] = $this->registry->get('GV_RootPath') . 'tmp/' . time() . '-JP'; $cmd .= sprintf(' -b -JpgFromRaw %s > %s' , $this->escapeshellargs($raw_datas->getPathname()) , $this->escapeshellargs($thisFile) ); $this->shell_cmd($cmd); $refSize = 0; $tmpFile = false; foreach ($tmpFiles as $file) { if (is_file($file) && filesize($file) > 0) { if (filesize($file) > $refSize) { $tmpFile = $file; $refSize = filesize($file); } else unlink($file); } else unlink($file); } if (!$tmpFile) throw new Exception('Unable to extract a preview for the raw imageFile'); rename($tmpFile, $dest); return $this; } }