Project

General

Profile

Feature #32898 » pdf-thumbnail-win-v2.patch

Go MAEDA, 2021-05-16 04:41

View differences:

lib/redmine/platform.rb
25 25
           (RUBY_PLATFORM == 'java' && /windows/i.match?(ENV['OS'] || ENV['os']))
26 26
      end
27 27

  
28
      def mswin64?
29
        mswin? && RUBY_PLATFORM.include?('x86_64')
30
      end
31

  
28 32
      def osx?
29 33
        (/(:?darwin)/.match?(RUBY_PLATFORM))
30 34
      end
lib/redmine/thumbnail.rb
24 24
    extend Redmine::Utils::Shell
25 25

  
26 26
    CONVERT_BIN = (Redmine::Configuration['imagemagick_convert_command'] || 'convert').freeze
27
    GS_BIN = (Redmine::Configuration['gs_command'] || 'gs').freeze
27
    GS_BIN = (
28
      Redmine::Configuration['gs_command'] ||
29
      ('gswin64c' if Redmine::Platform.mswin64?) ||
30
      ('gwwin32c' if Redmine::Platform.mswin?) ||
31
      'gs'
32
    ).freeze
28 33
    ALLOWED_TYPES = %w(image/bmp image/gif image/jpeg image/png application/pdf)
29 34

  
30 35
    # Generates a thumbnail for the source image to target
......
73 78
    def self.gs_available?
74 79
      return @gs_available if defined?(@gs_available)
75 80

  
76
      if Redmine::Platform.mswin?
81
      begin
82
        `#{shell_quote GS_BIN} -version`
83
        @gs_available = $?.success?
84
      rescue
77 85
        @gs_available = false
78
      else
79
        begin
80
          `#{shell_quote GS_BIN} -version`
81
          @gs_available = $?.success?
82
        rescue
83
          @gs_available = false
84
        end
85 86
      end
86 87
      logger.warn("gs binary (#{GS_BIN}) not available") unless @gs_available
87 88
      @gs_available
(2-2/3)