Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to Imagemagick 7 #4

Open
jdutant opened this issue Mar 21, 2024 · 0 comments
Open

Upgrade to Imagemagick 7 #4

jdutant opened this issue Mar 21, 2024 · 0 comments

Comments

@jdutant
Copy link

jdutant commented Mar 21, 2024

Not urgent.

I encountered the following bug: https://stackoverflow.com/questions/52998331/imagemagick-security-policy-pdf-blocking-conversion. Long story short, it would probably disappear if the repo used newer versions of Ghostscript / Imagemagick, more specifically, ImageMagick 7. Currently, the versions are from 2021:

$ gs -v
GPL Ghostscript 9.55.0 (2021-09-27)
Copyright (C) 2021 Artifex Software, Inc.  All rights reserved.
$ convert --version
Version: ImageMagick 6.9.11-60 Q16 aarch64 2021-01-25 https://imagemagick.org
Copyright: (C) 1999-2021 ImageMagick Studio LLC

Bug

I have a pdf image, fig1_galilean_spacetime.pdf (in 2023 issue 02 article 02) that I need to convert to SVG. I could do so with ImageMagick (convert). But I get an error:

$ convert -density 300 -units PixelsPerInch fig1_galilean_spacetime.pdf  -quality 90 fig1_galilean_spacetime.svg
convert-im6.q16: attempt to perform an operation not allowed by the security policy `PDF' @ error/constitute.c/IsCoderAuthorized/421.

(Note: there's an even neater way to convert. The TeX file has the class \documentclass[tikz,convert={outfile=\jobname.svg}]{standalone}. Running pdflatex -shell-escape fig1_galilean_spacetime.texautomatically runsconvert` with suitable parameters. But we get the error above.)

Explanation

As the discussion linked above explains, there was a security flaw in Ghostscript <= 9.24. Imagemagick uses Ghostscript to convert PDF files, and the security flaw would allow code embedded in PDF files to execute stuff on a computer. Imagemagick introduced a default policy to not convert PDF files, until Ghostscript was fixed.

Newer versions of Imagemagick don't appear to have the issue: when I run the conversion command on my system (rather than docker), it works. On my system, the versions are ImageMagick 7.1.1-26 and Ghostscript 10.02.1 (included in MacTeX, or perhaps I installed ImageMagick separately with Homebrew).

Otherwise, there's a temporary fix involving modifying Imagemagick's config file. It's explained in the Stackoverflow post above. But it'd be erased with updates, so it's safer to simply update the software at some point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant