1
0
mirror of https://github.com/vichan-devel/vichan.git synced 2024-11-12 01:50:48 +01:00

gifsicle: redirect stdout to /dev/null but keep stderr going to stdout

This commit is contained in:
Michael Foster 2013-08-04 16:32:36 -04:00
parent a3cf56a768
commit acfda35648
2 changed files with 5 additions and 4 deletions

View File

@ -1939,13 +1939,14 @@ function DNS($host) {
return $ip_addr; return $ip_addr;
} }
function shell_exec_error($command) { function shell_exec_error($command, $suppress_stdout = false) {
global $config, $debug; global $config, $debug;
if ($config['debug']) if ($config['debug'])
$start = microtime(true); $start = microtime(true);
$return = trim(shell_exec('PATH="' . escapeshellcmd($config['shell_path']) . ':$PATH";' . $command . ' 2>&1 && echo "TB_SUCCESS"')); $return = trim(shell_exec('PATH="' . escapeshellcmd($config['shell_path']) . ':$PATH";' .
$command . ' 2>&1 ' . ($suppress_stdout ? '> /dev/null ' : '') . '&& echo "TB_SUCCESS"'));
$return = preg_replace('/TB_SUCCESS$/', '', $return); $return = preg_replace('/TB_SUCCESS$/', '', $return);
if ($config['debug']) { if ($config['debug']) {

View File

@ -321,8 +321,8 @@ class ImageConvert extends ImageBase {
if ($this->format == 'gif' && ($config['thumb_ext'] == 'gif' || $config['thumb_ext'] == '') && $config['thumb_keep_animation_frames'] > 1) { if ($this->format == 'gif' && ($config['thumb_ext'] == 'gif' || $config['thumb_ext'] == '') && $config['thumb_keep_animation_frames'] > 1) {
if ($this->gifsicle) { if ($this->gifsicle) {
if (($error = shell_exec_error("gifsicle -w --unoptimize -O2 --resize {$this->width}x{$this->height} < " . if (($error = shell_exec_error("gifsicle -w --unoptimize -O2 --resize {$this->width}x{$this->height} < " .
escapeshellarg($this->src . '') . " \"#0-{$config['thumb_keep_animation_frames']}\" >/dev/null -o " . escapeshellarg($this->src . '') . " \"#0-{$config['thumb_keep_animation_frames']}\" -o " .
escapeshellarg($this->temp))) || !file_exists($this->temp)) escapeshellarg($this->temp), true)) || !file_exists($this->temp))
error('Failed to resize image!', null, $error); error('Failed to resize image!', null, $error);
} else { } else {
if ($config['convert_manual_orient'] && ($this->format == 'jpg' || $this->format == 'jpeg')) if ($config['convert_manual_orient'] && ($this->format == 'jpg' || $this->format == 'jpeg'))