imagemagick - convert not allowed [duplicate]
I have multiple *.jpeg
pictures I like to merge into a single *.pdf
file like so:
convert Blatt1.jpg Blatt2.jpg Blatt3.jpg Blatt4.jpg out.pdf
I am prompted with the following exception:
convert: attempt to perform an operation not allowed by the security policy `PDF' @ error/constitute.c/IsCoderAuthorized/408
What causes this problem and how can I fix it? I did some research but couldn't find anything about this particular problem.
ImageMagick has some security policies disabling some rights for security reasons. See why at the bottom of this answer.
You will have to edit a config file to re-enble the action you need.
Open /etc/ImageMagick-6/policy.xml
with your favorite text editor, find the line <policy domain="coder" rights="none" pattern="PDF" />
and replace "none"
by "read|write"
# Open the file
sudo nano /etc/ImageMagick-6/policy.xml
# find and edit the line
<policy domain="coder" rights="none" pattern="PDF" />
# to :
<policy domain="coder" rights="read|write" pattern="PDF" />
About ImageMagick security policy
The restricted policy is made to prevent unknown vulnerabilities coming from third party software as Ghostscript used here for PDF files. Be sure to update Ghostscript.
- https://imagemagick.org/script/security-policy.php
- https://snyk.io/vuln/search?type=linux&q=ghostscript
Because of a known bug with security implications, the conversion to pdf is disabled in ImageMagick convert
.
I suggest that you work around the problem,
- either
- Import the pictures into LibreOfffice and save the document.
- Export as pdf from LibreOffice.
- or
-
install img2pdf from the repository 'universe'
sudo apt install img2pdf
and run the following command line to create a
pdf
file with several pictures corresponding to the question or something similar for other cases,img2pdf --out out.pdf Blatt1.jpg Blatt2.jpg Blatt3.jpg Blatt4.jpg
-
There are details for fine tuning in the manual
man img2pdf
-