Each time you try to convert a JPG file to PDF using the command convert *.jpg pictures.pdf
, you receive the error message convert: not authorized 'pictures.pdf' @ error/constitute.c/WriteImage/1028
.
This problem occurs from a security update in the ImageMagick
package. A bug was reported in the Ubuntu bug tracker, and it's related to the kb.cert.org
security update.
One temporary solution is to edit the /etc/ImageMagick-6/policy.xml
file and change the PDF rights from none
to read|write
. This will allow you to convert images without any issues.
Another solution is to use the command pdftoppm -jpeg input.pdf output.jpg
from the poppler-utils
package. This command allows you to convert PDFs to JPEGs without using ImageMagick
.
A more straightforward solution is to use the sed
command to fix the policy.xml
file. You can create a one-liner command like this:
sudo sed -i 's#<policy domain="coder" rights="none" pattern="PDF" />#<policy domain="coder" rights="read|write" pattern="PDF" />#' /etc/ImageMagick-6/policy.xml
This will update the policy.xml
file and allow you to convert images without any issues.
If you prefer a more programmatic approach, you can create a script that updates the policy.xml
file automatically.
To fix this issue on your Ubuntu distribution, you can use any of the solutions above. The final solution involves running the sed
command to fix the policy.xml
file.
sudo sed -i 's#<policy domain="coder" rights="none" pattern="PDF" />#<policy domain="coder" rights="read|write" pattern="PDF" />#' /etc/ImageMagick-6/policy.xml
This will update the policy.xml
file and allow you to convert images without any issues.