From 58acb7128278c1523d9279ac8b81a8dfedb00a98 Mon Sep 17 00:00:00 2001 From: Matthew Barbour Date: Fri, 14 Jun 2019 12:59:12 -0500 Subject: [PATCH] Change imagemagick commands to return the error output Added ico to transcode extension --- core/imageboard/misc.php | 7 +++++-- ext/transcode/main.php | 14 +++++++++++--- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/core/imageboard/misc.php b/core/imageboard/misc.php index e3e31576..e9bd93c6 100644 --- a/core/imageboard/misc.php +++ b/core/imageboard/misc.php @@ -208,8 +208,11 @@ function create_thumbnail_convert($hash, $input_type = ""): bool $cmd = sprintf($format, $convert, $w, $h, $options, $q, $bg,$input_type, $inname, $type, $outname); $cmd = str_replace("\"convert\"", "convert", $cmd); // quotes are only needed if the path to convert contains a space; some other times, quotes break things, see github bug #27 exec($cmd, $output, $ret); - - log_debug('handle_pixel', "Generating thumbnail with command `$cmd`, returns $ret"); + if ($ret!=0) { + log_warning('imageboard/misc', "Generating thumbnail with command `$cmd`, returns $ret, outputting ".implode("\r\n",$output)); + } else { + log_debug('imageboard/misc', "Generating thumbnail with command `$cmd`, returns $ret"); + } if ($config->get_bool("thumb_optim", false)) { exec("jpegoptim $outname", $output, $ret); diff --git a/ext/transcode/main.php b/ext/transcode/main.php index 85c554d8..aa471d0a 100644 --- a/ext/transcode/main.php +++ b/ext/transcode/main.php @@ -43,6 +43,7 @@ class TranscodeImage extends Extension "psd", "tiff", "webp", + "ico", ] ]; @@ -68,6 +69,7 @@ class TranscodeImage extends Extension const INPUT_FORMATS = [ "BMP" => "bmp", "GIF" => "gif", + "ICO" => "ico", "JPG" => "jpg", "PNG" => "png", "PSD" => "psd", @@ -440,15 +442,21 @@ class TranscodeImage extends Extension } $tmp_name = tempnam("/tmp", "shimmie_transcode"); - $format = '"%s" %s -quality %u -background %s "%s" %s:"%s"'; - $cmd = sprintf($format, $convert, $args, $q, $bg, $source_name, $ext, $tmp_name); + $source_type = ""; + switch ($source_format) { + case "ico": + $source_type = "ico:"; + } + + $format = '"%s" %s -quality %u -background %s %s"%s" %s:"%s" 2>&1'; + $cmd = sprintf($format, $convert, $args, $q, $bg, $source_type, $source_name, $ext, $tmp_name); $cmd = str_replace("\"convert\"", "convert", $cmd); // quotes are only needed if the path to convert contains a space; some other times, quotes break things, see github bug #27 exec($cmd, $output, $ret); log_debug('transcode', "Transcoding with command `$cmd`, returns $ret"); if ($ret!==0) { - throw new ImageTranscodeException("Transcoding failed with command ".$cmd); + throw new ImageTranscodeException("Transcoding failed with command ".$cmd.", returning ".implode("\r\n", $output)); } return $tmp_name;