IQSS / dataverse

Open source research data repository software
http://dataverse.org
Other
876 stars 484 forks source link

support GraphicsMagick #8014

Open donsizemore opened 3 years ago

donsizemore commented 3 years ago

Dataverse uses ImageMagick to generate thumbnails from PDFs, by checking for /usr/bin/convert

On RHEL8-family systems, the newer and more secure GraphicsMagick fork ships with the OS, binary /usr/bin/gm

It would be nice for Dataverse to check first for gm, then the convert binary.

pdurbin commented 2 years ago

While working on #8160 I realized that dev environments don't typically generate thumbnails.

I tried installing (with Homebrew) and using GraphicsMagick on my Mac but I couldn't get to work. I even tried symlinking convert to gm since @donsizemore mentioned that's what he does. In all cases I get an "Unrecognized command" error like below (if I bump up logging) with an exit code of 1:

/usr/local/bin/gm pdf:/usr/local/payara5/glassfish/domains/domain1/files/10.5072/FK2/2NRY6P/17d7177471e-e4bfd5f50676[0] -thumbnail 400x400 -flatten -strip png:/usr/local/payara5/glassfish/domains/domain1/files/10.5072/FK2/2NRY6P/17d7177471e-e4bfd5f50676.thumb400

/usr/local/bin/gm: Unrecognized command 'pdf:/usr/local/payara5/glassfish/domains/domain1/files/10.5072/FK2/2NRY6P/17d7177471e-e4bfd5f50676[0]'. Use -help for a usage summary or see manual..

I installed ImageMagick instead and it just worked (version 7.1.0-16). Again, this is on a Mac using Homebrew. The version of GraphicsMagick that didn't work for me was 1.3.36.

donsizemore commented 2 years ago

@pdurbin the trick seems to be calling GraphicsMagick as /usr/bin/convert which succeeds on Linux:

[dls@dataverse5 ~]$ ls -al /usr/bin/convert 
lrwxrwxrwx. 1 root root 2 Nov 30 10:48 /usr/bin/convert -> gm
[dls@dataverse5 ~]$ convert pdf:CommunityDiskBackup.pdf -thumbnail 400x400 -flatten -strip png:test.png
[dls@dataverse5 ~]$ ls -al test.png 
-rw-rw-r--. 1 dls dls 8964 Nov 30 11:05 test.png

It would be far preferable for Dataverse to more smartly handle the GraphicsMagick case (which might instead mean the use of a native Java library rather than calling an external binary?).

pdurbin commented 2 years ago

@donsizemore yeah, I don't know why the symlink trick doesn't work on Mac. If it helps I'm on macOS Catalina 10.15.7.

donsizemore commented 2 years ago

@pdurbin this works on a test Dataverse server (Rocky Linux, GraphicsMagick-1.3.36):

$ gm convert -thumbnail 400 -flatten -strip CommunityDiskBackup.pdf[0] test.png

and this works on my Mac (Monterrey, GraphicsMagick-1.3.36 via MacPorts):

$ gm convert -thumbnail 400 -flatten -strip "H602v7.pdf[0]" h602.png