Defect #33283

Thumbnail support for PDF attachments may not be detected

Added by VVD VVD 4 months ago. Updated about 1 month ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:Go MAEDA% Done:

0%

Category:Attachments
Target version:4.1.2
Resolution:Fixed Affected version:4.1.1

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

33283.patch Magnifier (1.25 KB) Marius BALTEANU, 2020-04-19 19:50


Related issues

Related to Redmine - Feature #22481: Show thumbnails for PDF attachments Closed
Related to Redmine - Patch #32898: Let's show PDF thumbnails on Windows. Closed

Associated revisions

Revision 19712
Added by Go MAEDA 4 months ago

Fix that thumbnail support for PDF attachments may not be detected (#33283).

Patch by VVD VVD.

Revision 19713
Added by Go MAEDA 4 months ago

Merged r19712 from trunk to 4.1-stable (#33283).

History

#1 Updated by Marius BALTEANU 4 months ago

  • Target version set to Candidate for next major release

#2 Updated by VVD VVD 4 months ago

Why "Candidate for next major release"?
It's so small and obvious fix!

#3 Updated by Marius BALTEANU 4 months ago

  • File 33283.patchMagnifier added
  • Target version changed from Candidate for next major release to 4.1.2

The patch looks good to me and the tests pass.

VVD VVD wrote:

Why "Candidate for next major release"?
It's so small and obvious fix!

It was just an initial target version, but I don't see a real problem to deliver this fix in 4.1.2. I've created a patch file from the diff.

#4 Updated by VVD VVD 4 months ago

Thanks.

Just checked - for create attachment thumbnails of PDF files used convert. And gs binary isn't necessary.

#5 Updated by Go MAEDA 4 months ago

  • Related to Feature #22481: Show thumbnails for PDF attachments added

#6 Updated by Go MAEDA 4 months ago

  • Subject changed from Can't detect support of thumbnails for PDF attachments to Thumbnail support for PDF attachments may not be detected
  • Status changed from New to Closed
  • Assignee set to Go MAEDA
  • Resolution set to Fixed

Committed the patch. Thank you.

#7 Updated by VVD VVD 4 months ago

Thanks!

#8 Updated by David Gessel about 1 month ago

Thanks for this patch - just tested this patch on a FreeBSD 11.3 install where the ports version is currently redmine4-4.1.1_2 and the patch and configuration.yml modification resulted in pdf support finally being available. :-)

- ghostscript9-agpl-base-9.52_5
- ImageMagick7-nox11-7.0.10.6
- rubygem-mini_magick-4.10.1

Success. Thanks.

#9 Updated by Go MAEDA about 1 month ago

  • Related to Patch #32898: Let's show PDF thumbnails on Windows. added

Also available in: Atom PDF