Security policy PDF error in Imagick in Laravel app hosted on Azure

Pankaj S Y 1 Reputation point
2021-07-27T14:52:57.76+00:00

Below is the Imagick code reading a PDF file.

$img = new Imagick();
    $img->setResolution(300,300);
    $img->readImage($pdffile);

Below error appears in the log->

production.ERROR: attempt to perform an operation not allowed by the security policy `PDF' @ error/constitute.c/IsCoderAuthorized/408 {"userI
d":1,"exception":"[object] (ImagickException(code: 499): attempt to perform an operation not allowed by the security policy `PDF' @ error/constitute.c/IsCoderAutho
rized/408 at /home/site/wwwroot/app/Http/Controllers/Sample.php:2812)
[stacktrace]
#0 /home/site/wwwroot/app/Http/Controllers/Sample.php(2812): Imagick->readimage('/tmp/phpPPIrAu')

I added policy code in /etc/ImageMagick-6/policy.xml but no effect.

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
7,895 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Ryan Hill 28,546 Reputation points Microsoft Employee
    2021-08-09T23:27:16.453+00:00

    @Pankaj S Y , there's this answer that have been successful for others.

    If that doesn't help, how did you setup the extension. Do you see any errors when running composer? Does phpinfo return the extension loaded correctly?

    802a8956-2440-11e7-9b68-60e7e678a49b.png


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.