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

ImageMagick failure on Ubuntu 18.04 #67

Closed
AndreasAlbert opened this issue Nov 23, 2018 · 3 comments
Closed

ImageMagick failure on Ubuntu 18.04 #67

AndreasAlbert opened this issue Nov 23, 2018 · 3 comments
Labels
wontfix This will not be worked on

Comments

@AndreasAlbert
Copy link
Collaborator

There seems to be an issue with convert failing on Ubuntu 18.04. If you see errors like this one:

RuntimeError: convert-im6.q16: not authorized `input/PDF/Figure_004.pdf' @ error/constitute.c/ReadImage/412.

you can check out this fix on stackoverflow. It seems that ImageMagick now prohibits certain operations by default to avoid security vulnerabilities due to malicious code embedded in certain media files. Unfortunately, the fix requires the user to edit the policy file /etc/ImageMagick-6/policy.xml, which requires admin privileges. I am not sure what exactly triggers the issue, so it's hard to say how many users will be affected. If this becomes a widespread problem, we should look into replacing our use of ImageMagick with something else.

@clelange
Copy link
Collaborator

Probably related, this is also causing issues when using SWAN (both python3 and legacy python stacks):

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-5-58ae0b37a4f9> in <module>
      3 table.add_variable(exp)
      4 submission.add_table(table)
----> 5 submission.create_files("example_output")

~/.local/lib/python3.6/site-packages/hepdata_lib/__init__.py in create_files(self, outdir)
    478         # Write all the tables
    479         for table in self.tables:
--> 480             table.write_output(outdir)
    481 
    482         # Copy additional resource files

~/.local/lib/python3.6/site-packages/hepdata_lib/__init__.py in write_output(self, outdir)
    229         :type outdir: string
    230         """
--> 231         self.write_images(outdir)
    232         self.write_yaml(outdir)
    233 

~/.local/lib/python3.6/site-packages/hepdata_lib/__init__.py in write_images(self, outdir)
    251             command = "convert -flatten -fuzz 1% -trim +repage {} {}/{}".format(
    252                 image_file, outdir, out_image_file)
--> 253             command_ok = helpers.execute_command(command)
    254             if not command_ok:
    255                 print("ImageMagick does not seem to be installed \

~/.local/lib/python3.6/site-packages/hepdata_lib/helpers.py in execute_command(command)
     35         for line in proc.stderr:
     36             result = result + line
---> 37         raise RuntimeError(result)
     38     return True
     39 

RuntimeError: convert: UnableToOpenConfigureFile `magic.xml' @ warning/configure.c/GetConfigureOptions/714.
convert: UnableToOpenConfigureFile `delegates.xml' @ warning/configure.c/GetConfigureOptions/714.
convert: FailedToExecuteCommand `'gs' -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 '-sDEVICE=pngalpha' -dTextAlphaBits=4 -dGraphicsAlphaBits=4 '-r72x72'  '-sOutputFile=/tmp/magick-400EDeqaEdlyWFq%d' '-f/tmp/magick-400p772kieSgsyo' '-f/tmp/magick-400wdnbYQGQ4Erm'' (1) @ error/pdf.c/InvokePDFDelegate/291.
convert: NoImagesDefined `example_output/Figure_006-a.png' @ error/convert.c/ConvertImageCommand/3275.

@AndreasAlbert
Copy link
Collaborator Author

I tried running the image conversion also in our tests in #73, but the conversion fails like this:

E           RuntimeError: convert.im6: Postscript delegate failed `/home/travis/build/HEPData/hepdata_lib/examples/example_inputs/signalEffVsMass.pdf': No such file or directory @ error/pdf.c/ReadPDFImage/677.
E           convert.im6: no images defined `test_output/signalEffVsMass.png' @ error/convert.c/ConvertImageCommand/3044.
hepdata_lib/helpers.py:37: RuntimeError

While that error looks like there is a missing file, I do not think that that is possible, since our code explicitly checks the existence of the file before running the command.

See build log

@AndreasAlbert
Copy link
Collaborator Author

(It does succeed starting from a PNG, though. Only PDF inputs fail.)

@clelange clelange added the wontfix This will not be worked on label May 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants