mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-05-09 04:56:06 +00:00
add extension to temp file, because this is needed for programms like unoconv
This commit is contained in:
parent
9734d57ff3
commit
31db5f69fe
|
@ -126,11 +126,6 @@ class SeedDMS_ConversionServiceExec extends SeedDMS_ConversionServiceBase {
|
||||||
/* if no %f placeholder is found, we assume output to stdout */
|
/* if no %f placeholder is found, we assume output to stdout */
|
||||||
$tostdout = strpos($this->cmd, '%o') === false;
|
$tostdout = strpos($this->cmd, '%o') === false;
|
||||||
|
|
||||||
$start = microtime(true);
|
|
||||||
if(!$target && !$tostdout)
|
|
||||||
$tmpfile = tempnam(sys_get_temp_dir(), 'convert');
|
|
||||||
else
|
|
||||||
$tmpfile = $target;
|
|
||||||
$format = '';
|
$format = '';
|
||||||
switch($this->to) {
|
switch($this->to) {
|
||||||
case 'image/gif':
|
case 'image/gif':
|
||||||
|
@ -143,7 +138,22 @@ class SeedDMS_ConversionServiceExec extends SeedDMS_ConversionServiceBase {
|
||||||
case 'image/png':
|
case 'image/png':
|
||||||
$format = 'png';
|
$format = 'png';
|
||||||
break;
|
break;
|
||||||
|
case 'application/pdf':
|
||||||
|
$format = 'pdf';
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
$start = microtime(true);
|
||||||
|
$hastempfile = false;
|
||||||
|
if(!$target && !$tostdout) {
|
||||||
|
$tmpfile = tempnam(sys_get_temp_dir(), 'convert');
|
||||||
|
/* Some programms (e.g. unoconv) need the output file to have the
|
||||||
|
* right extension. Without an extension it will add one by itself.
|
||||||
|
*/
|
||||||
|
if($format)
|
||||||
|
rename($tmpfile, $tmpfile .= '.'.$format);
|
||||||
|
$hastempfile = true;
|
||||||
|
} else
|
||||||
|
$tmpfile = $target;
|
||||||
/* %s was just added because the commands to convert to text/plain used
|
/* %s was just added because the commands to convert to text/plain used
|
||||||
* it instead of %f for the input file
|
* it instead of %f for the input file
|
||||||
* %f = input file
|
* %f = input file
|
||||||
|
@ -151,10 +161,12 @@ class SeedDMS_ConversionServiceExec extends SeedDMS_ConversionServiceBase {
|
||||||
* %m = mime type
|
* %m = mime type
|
||||||
* %w = width
|
* %w = width
|
||||||
*/
|
*/
|
||||||
$cmd = str_replace(array('%w', '%f', '%s', '%if', '%o', '%m'), array(isset($params['width']) ? $params['width'] : '150', $infile, $infile, $format, $tmpfile, $this->from), $this->cmd);
|
$cmd = str_replace(array('%w', '%f', '%s', '%if', '%o', '%m'), array(!empty($params['width']) ? (int) $params['width'] : '150', $infile, $infile, $format, $tmpfile, $this->from), $this->cmd);
|
||||||
try {
|
try {
|
||||||
$ret = self::execWithTimeout($cmd, $this->timeout);
|
$ret = self::execWithTimeout($cmd, $this->timeout);
|
||||||
} catch(Exception $e) {
|
} catch(Exception $e) {
|
||||||
|
if($hastempfile)
|
||||||
|
unlink($tmpfile);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$end = microtime(true);
|
$end = microtime(true);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user