Feature #32898

PDF thumbnails support on Windows

Added by taca tadocolo over 1 year ago. Updated 4 months ago.

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

0%

Category:Attachments
Target version:5.0.0
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

pdf-thumbnail-win.patch Magnifier (1.78 KB) Go MAEDA, 2021-03-31 15:40

pdf-thumbnail-win-v2.patch Magnifier (1.71 KB) Go MAEDA, 2021-05-16 04:41

pdf-thumbnail-win-v3.patch Magnifier (1.22 KB) Go MAEDA, 2021-05-23 08:40


Related issues

Related to Redmine - Feature #22481: Show thumbnails for PDF attachments Closed
Related to Redmine - Defect #33283: Thumbnail support for PDF attachments may not be detected Closed

Associated revisions

Revision 21008
Added by Go MAEDA 4 months ago

PDF thumbnails support on Windows (#32898).

History

#1 Updated by Go MAEDA over 1 year ago

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

#2 Updated by Go MAEDA about 1 year ago

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

#3 Updated by Go MAEDA about 1 year 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".

#4 Updated by Steve Zhou 6 months 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

#5 Updated by Go MAEDA 6 months 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.

#6 Updated by Steve Zhou 6 months 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.

#7 Updated by Go MAEDA 6 months 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.

#8 Updated by Steve Zhou 6 months 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.

#9 Updated by Go MAEDA 4 months ago

  • Target version set to Candidate for next major release

#10 Updated by Go MAEDA 4 months ago

#11 Updated by Go MAEDA 4 months 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.

#12 Updated by Go MAEDA 4 months 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.

#13 Updated by Go MAEDA 4 months 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.

Also available in: Atom PDF