Project

General

Profile

Actions

Defect #33283

closed

Thumbnail support for PDF attachments may not be detected

Added by VVD VVD over 4 years ago. Updated about 3 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Attachments
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Fixed
Affected version:

Description

In lib/redmine/thumbnail.rb:

        begin
          `gs -version`
          @gs_available = $?.success?
        rescue
          @gs_available = false
        end

Can't detect ImageMagick PDF support.

But if I add full path to gs:

        begin
          `/usr/local/bin/gs -version`
          @gs_available = $?.success?
        rescue
          @gs_available = false
        end

then it detects ImageMagick PDF suport.

Patch for 4.1.1 to fix it:

--- config/configuration.yml.example.orig
+++ config/configuration.yml.example
@@ -179,6 +179,10 @@
   # the ImageMagick's `convert` binary. Used to generate attachment thumbnails.
   #imagemagick_convert_command:

+  # Absolute path (e.g. /usr/bin/gs, c:/ghostscript/gs.exe) to
+  # the `gs` binary. Used to generate attachment thumbnails of PDF files.
+  #gs_command:
+
   # Configuration of MiniMagick font.
   #
   # Redmine uses MiniMagick in order to export a gantt chart to a PNG image.

--- lib/redmine/thumbnail.rb.orig
+++ lib/redmine/thumbnail.rb
@@ -25,6 +25,7 @@
     extend Redmine::Utils::Shell

     CONVERT_BIN = (Redmine::Configuration['imagemagick_convert_command'] || 'convert').freeze
+    GS_BIN = (Redmine::Configuration['gs_command'] || 'gs').freeze
     ALLOWED_TYPES = %w(image/bmp image/gif image/jpeg image/png application/pdf)

     # Generates a thumbnail for the source image to target
@@ -79,12 +80,13 @@
         @gs_available = false
       else
         begin
-          `gs -version`
+          `#{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
     end


Files

33283.patch (1.25 KB) 33283.patch Marius BĂLTEANU, 2020-04-19 19:50

Related issues

Related to Redmine - Feature #22481: Show thumbnails for PDF attachmentsClosedGo MAEDA

Actions
Related to Redmine - Feature #32898: PDF thumbnails support on WindowsClosedGo MAEDA

Actions
Actions

Also available in: Atom PDF