プロジェクト

全般

プロフィール

Vote #80805

完了

Thumbnail support for PDF attachments may not be detected

Admin Redmine さんが3年以上前に追加. 3年以上前に更新.

ステータス:
Closed
優先度:
通常
担当者:
-
カテゴリ:
Attachments_19
対象バージョン:
開始日:
2022/05/09
期日:
進捗率:

0%

予定工数:
category_id:
19
version_id:
162
issue_org_id:
33283
author_id:
49691
assigned_to_id:
332
comments:
9
status_id:
5
tracker_id:
1
plus1:
0
affected_version:
closed_on:
affected_version_id:
160
ステータス-->[Closed]

説明

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

journals

--------------------------------------------------------------------------------
Why "Candidate for next major release"?
It's so small and obvious fix!
--------------------------------------------------------------------------------
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 version:"4.1.2". I've created a patch file from the diff.

--------------------------------------------------------------------------------
Thanks.

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

--------------------------------------------------------------------------------
Committed the patch. Thank you.
--------------------------------------------------------------------------------
Thanks!
--------------------------------------------------------------------------------
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.
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------


related_issues

relates,Closed,22481,Show thumbnails for PDF attachments
relates,Closed,32898,PDF thumbnails support on Windows

Admin Redmine さんが3年以上前に更新

  • カテゴリAttachments_19 にセット
  • 対象バージョン4.1.2_162 にセット

他の形式にエクスポート: Atom PDF

いいね!0
いいね!0