diff --git a/lib/redmine/platform.rb b/lib/redmine/platform.rb index 4696fa76c..fa735be4b 100644 --- a/lib/redmine/platform.rb +++ b/lib/redmine/platform.rb @@ -20,6 +20,10 @@ module Redmine module Platform class << self + def mswin64? + mswin? && RUBY_PLATFORM.include?('x86_64') + end + def mswin? (/(:?mswin|mingw)/.match?(RUBY_PLATFORM)) || (RUBY_PLATFORM == 'java' && /windows/i.match?(ENV['OS'] || ENV['os'])) diff --git a/lib/redmine/thumbnail.rb b/lib/redmine/thumbnail.rb index 4bee4085a..5c3e18cc6 100644 --- a/lib/redmine/thumbnail.rb +++ b/lib/redmine/thumbnail.rb @@ -24,7 +24,13 @@ module Redmine extend Redmine::Utils::Shell CONVERT_BIN = (Redmine::Configuration['imagemagick_convert_command'] || 'convert').freeze - GS_BIN = (Redmine::Configuration['gs_command'] || 'gs').freeze + DEFAULT_GS_COMMAND = + if Redmine::Platform.mswin? + Redmine::Platform.mswin64? ? 'gswin64c' : 'gswin32c' + else + 'gs' + end + GS_BIN = (Redmine::Configuration['gs_command'] || DEFAULT_GS_COMMAND).freeze ALLOWED_TYPES = %w(image/bmp image/gif image/jpeg image/png application/pdf) # Generates a thumbnail for the source image to target @@ -73,15 +79,11 @@ module Redmine def self.gs_available? return @gs_available if defined?(@gs_available) - if Redmine::Platform.mswin? + begin + `#{shell_quote GS_BIN} -version` + @gs_available = $?.success? + rescue @gs_available = false - else - begin - `#{shell_quote GS_BIN} -version` - @gs_available = $?.success? - rescue - @gs_available = false - end end logger.warn("gs binary (#{GS_BIN}) not available") unless @gs_available @gs_available