Defect #33283
closedThumbnail support for PDF attachments may not be detected
0%
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
Related issues
Updated by Marius BĂLTEANU over 4 years ago
- Target version set to Candidate for next major release
Updated by VVD VVD over 4 years ago
Why "Candidate for next major release"?
It's so small and obvious fix!
Updated by Marius BĂLTEANU over 4 years ago
- File 33283.patch 33283.patch 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.
Updated by VVD VVD over 4 years ago
Thanks.
Just checked - for create attachment thumbnails of PDF files used convert. And gs binary isn't necessary.
Updated by Go MAEDA over 4 years ago
- Related to Feature #22481: Show thumbnails for PDF attachments added
Updated by Go MAEDA over 4 years 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.
Updated by David Gessel over 4 years 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.
Updated by Go MAEDA over 4 years ago
- Related to Feature #32898: PDF thumbnails support on Windows added