Project

General

Profile

Actions

Feature #32898

closed

PDF thumbnails support on Windows

Added by Anonymous almost 5 years ago. Updated over 3 years ago.

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

0%

Estimated time:
Resolution:
Fixed

Description

Redmine 4.1.0 don't support PDF thumbnails on Windows. ( #22481 )
For Windows, "gswin64c(32c).exe"(command line version) can be used instead of "gswin64(32).exe".
By applying this diff, we can detect the presence of Ghostscript on Windows without side effects.

--- org/lib/redmine/thumbnail.rb
+++ patch/lib/redmine/thumbnail.rb
@@ -77,5 +77,6 @@

       if Redmine::Platform.mswin?
-        @gs_available = false
+        @gs_available = system("gswin64c -version > nul 2>&1") rescue false
+        @gs_available ||= system("gswin32c -version > nul 2>&1") rescue false
       else
         begin


Files

pdf-thumbnail-win.patch (1.78 KB) pdf-thumbnail-win.patch Go MAEDA, 2021-03-31 15:40
pdf-thumbnail-win-v2.patch (1.71 KB) pdf-thumbnail-win-v2.patch Go MAEDA, 2021-05-16 04:41
pdf-thumbnail-win-v3.patch (1.22 KB) pdf-thumbnail-win-v3.patch Go MAEDA, 2021-05-23 08:40

Related issues

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

Actions
Related to Redmine - Defect #33283: Thumbnail support for PDF attachments may not be detectedClosedGo MAEDA

Actions
Actions #1

Updated by Go MAEDA almost 5 years ago

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

Updated by Go MAEDA over 4 years ago

  • Related to Defect #33283: Thumbnail support for PDF attachments may not be detected added
Actions #3

Updated by Go MAEDA over 4 years ago

  • Status changed from New to Closed

Redmine 4.1.2 will support a new setting gs_command in config/configuration.yml (#33283). You can set the command name such as "gswin64c" and "gswin32c".

Actions #4

Updated by Steve Zhou almost 4 years ago

Go MAEDA wrote:

Redmine 4.1.2 will support a new setting gs_command in config/configuration.yml (#33283). You can set the command name such as "gswin64c" and "gswin32c".

I checked this new setting again, please find the result as below.

[Environment]
OS: Windows 10 x64
Redmine:4.2.0
Imagemagick: 6.9.8
Ghostscript: 9.21

[Case 1]
Set gs_command in config/configuration.yml
Result: ImageMagick PDF support available (optional) in Information page is not checked.

[Case 2]
No setting gs_command in config/configuration.yml
But change /lib/redmine/thumbnail.rb with the code "@gs_available = system("gswin64c -version > nul 2>&1") rescue false"
Result: ImageMagick PDF support available (optional) in Information page is checked and convert cmd is working in windows.

So, could you please change the code in /lib/redmine/thumbnail.rb, then the gs_command can also be worked in windows.
If gs_command is set, there is no need to judge operating system environment.

begin
`#{shell_quote GS_BIN} -version`
@gs_available = $?.success?
rescue
@gs_available = false
end
Actions #5

Updated by Go MAEDA almost 4 years ago

Steve Zhou, thank you for your feedback.

Could you try the attached patch without setting imagemagick_convert_command in configuration.yml? I think it should successfully show PDF thumbnails on Windows.

After applying the patch, Redmine will determine whether it should use gswin64c or gswin32c if you are running Redmine on Windows.

Actions #6

Updated by Steve Zhou over 3 years ago

Go MAEDA wrote:

Steve Zhou, thank you for your feedback.

Could you try the attached patch without setting imagemagick_convert_command in configuration.yml? I think it should successfully show PDF thumbnails on Windows.

After applying the patch, Redmine will determine whether it should use gswin64c or gswin32c if you are running Redmine on Windows.

MAEDA-san, I tested the patch, it can successfully show PDF thumbnails on Windows with setting imagemagick_convert_command and gs_command in configuration.yml.
But without the setting in configuration.yml, (instead, configuring path in environment variables), it cannot show PDF thumbnails.

Actions #7

Updated by Go MAEDA over 3 years ago

Steve Zhou wrote:

MAEDA-san, I tested the patch, it can successfully show PDF thumbnails on Windows with setting imagemagick_convert_command and gs_command in configuration.yml.
But without the setting in configuration.yml, (instead, configuring path in environment variables), it cannot show PDF thumbnails.

Zhou先生, thank you for testing the patch.

As you wrote, now I understood that rejecting Windows is not necessary. I will try to make it possible to display PDF thumbnails on Windows in a near future release.

Actions #8

Updated by Steve Zhou over 3 years ago

Go MAEDA wrote:

Steve Zhou wrote:

MAEDA-san, I tested the patch, it can successfully show PDF thumbnails on Windows with setting imagemagick_convert_command and gs_command in configuration.yml.
But without the setting in configuration.yml, (instead, configuring path in environment variables), it cannot show PDF thumbnails.

Zhou先生, thank you for testing the patch.

As you wrote, now I understood that rejecting Windows is not necessary. I will try to make it possible to display PDF thumbnails on Windows in a near future release.

Well noted with thanks.

Actions #9

Updated by Go MAEDA over 3 years ago

  • Target version set to Candidate for next major release
Actions #11

Updated by Go MAEDA over 3 years ago

  • Tracker changed from Patch to Feature
  • Subject changed from Let's show PDF thumbnails on Windows. to PDF thumbnails support on Windows
  • Target version changed from Candidate for next major release to 5.0.0

Setting the target version to 5.0.0.

Actions #12

Updated by Go MAEDA over 3 years ago

Removed the code for 32bit Windows from the patch.

I think there are very few people running Redmine on 32bit Windows now, so there is little need to add a method that checks for 32bit Windows to lib/redmine/platform.rb.

If you are using the 32bit version of gswin32c.exe, you can still generate PDF thumbnails by setting gs_command in configuration.yml.

Actions #13

Updated by Go MAEDA over 3 years ago

  • Status changed from New to Closed
  • Assignee set to Go MAEDA
  • Resolution set to Fixed

Committed the patch. Thank you all for your contribution.

Actions

Also available in: Atom PDF