diff --git a/lib/redmine/thumbnail.rb b/lib/redmine/thumbnail.rb index 2f9b41ce8..611c36703 100644 --- a/lib/redmine/thumbnail.rb +++ b/lib/redmine/thumbnail.rb @@ -24,6 +24,7 @@ module Redmine extend Redmine::Utils::Shell CONVERT_BIN = (Redmine::Configuration['imagemagick_convert_command'] || 'convert').freeze + CONVERT_TIMEOUT = 10 GS_BIN = ( Redmine::Configuration['gs_command'] || ('gswin64c' if Redmine::Platform.mswin?) || @@ -47,9 +48,9 @@ module Redmine size_option = "#{size}x#{size}>" if is_pdf - cmd = "#{shell_quote CONVERT_BIN} #{shell_quote "#{source}[0]"} -thumbnail #{shell_quote size_option} #{shell_quote "png:#{target}"}" + cmd = "#{shell_quote CONVERT_BIN} -limit time #{shell_quote CONVERT_TIMEOUT.to_s} #{shell_quote "#{source}[0]"} -thumbnail #{shell_quote size_option} #{shell_quote "png:#{target}"}" else - cmd = "#{shell_quote CONVERT_BIN} #{shell_quote source} -auto-orient -thumbnail #{shell_quote size_option} #{shell_quote target}" + cmd = "#{shell_quote CONVERT_BIN} -limit time #{shell_quote CONVERT_TIMEOUT.to_s} #{shell_quote source} -auto-orient -thumbnail #{shell_quote size_option} #{shell_quote target}" end unless system(cmd) logger.error("Creating thumbnail failed (#{$?}):\nCommand: #{cmd}")