imagemagick-policy-fix.sh 758 B

12345678910111213141516171819202122232425262728293031
  1. #!/usr/bin/env bash
  2. set -euo pipefail # bash strict mode
  3. require_sudo(){
  4. if [[ $EUID -ne 0 ]]; then
  5. echo "Please run as superuser! Try running:"
  6. echo "sudo ${0}"
  7. exit 2
  8. fi
  9. }
  10. require_sudo
  11. dt=$(date +%F-%H%M%S)
  12. file="/etc/ImageMagick-6/policy.xml"
  13. backup="${file}.backup.${dt}"
  14. # backup config
  15. cp "$file" "$backup"
  16. # filesize for converting images
  17. old='<policy domain="resource" name="memory" value="256MiB"/>'
  18. new='<policy domain="resource" name="memory" value="4GiB"/>'
  19. sed -i "s#${old}#${new}#g" "$file"
  20. # filesize for converting pdfs
  21. old='<policy domain="resource" name="map" value="512MiB"/>'
  22. new='<policy domain="resource" name="map" value="4GiB"/>'
  23. sed -i "s#${old}#${new}#g" "$file"
  24. diff --color "$backup" "$file"