PHP ImagickException: not authorized

前端 未结 4 1639
时光取名叫无心
时光取名叫无心 2020-12-14 00:46

Any ideas how to fix this ?

 ImagickException: not authorized `/tmp/magick-1552lvf2nIjaqx1W\' @ error/constitute.c/ReadImage/412 

I thought

相关标签:
4条回答
  • 2020-12-14 01:07

    i hope this solution will help you I'm facing the same issue and I'm on the live server i'm trying to follow above Mikel Annjuk and hakre answer so i cannot the change the file /etc/ImageMagick/policy.xml so i contact to the server provider to edit file and send this url to follow step but there is answering me

    " I am still working on this. The solution given in above link requires root access to the server which is not possible in a shared server. But imagick is related to php. So let me try changing php version and see if that helps"

    when i tired to resolve this on that time i have idea may be the issue of the file path where I'm saving the file so I change to base path to FCPATH and the matter is solved. i'm using Codeigniter base_url() to php FCPATH this is the point to solve this issue

    but on svg converter show "no decode delegate" issue

    add the following lines in the start of file or code

    like this

    $usmap = file_get_contents(base_url('convert/plus.svg')); 
         $find_string   = '<svg';
    $position = strpos($usmap, $find_string);
    
       $svg_file_new ='<?xml version="1.0" encoding="UTF-8" standalone="no"?>'.substr($usmap, $position).'</svg>';
           file_put_contents(FCPATH.'convert/plus.svg', $svg_file_new);
    
            $usmap = base_url('convert/plus.svg'); 
    $im = new Imagick($usmap);  
    $im->setImageFormat("jpg"); 
    
    $im->writeImage(FCPATH .'convert/plus.jpg');
    $im->clear();
    $im->destroy();
    

    above code first, get the SVG code from the file and add XML version code then put it into the file and then convert SVG to any type of image like jpg

    sorry for my English

    0 讨论(0)
  • 2020-12-14 01:12

    An "strace" of the PHP process shown the following:

    sh: inkscape: command not found

    I fixed this by:

    apt-get install inkscape
    
    0 讨论(0)
  • 2020-12-14 01:13

    I have followed the below Steps to fix the Fatal error:

    Uncaught ImagickException: not authorized `../../c02_001.pdf'
    @ error/constitute.c/ReadImage/412 
    

    1. sudo vi policy.xml from etc/Imagemagick-6/
    2. comment the following line

      <!-- <policy domain="coder" rights="none" pattern="MVG" /> -->
      
    3. Rewrite the following line

      <policy domain="coder" rights="none" pattern="PDF" />
      

      to

      <policy domain="coder" rights="read|write" pattern="PDF" />
      
    4. sudo apt-get install inkscape

    5. Restart apache with following command sudo restart apache2
    0 讨论(0)
  • 2020-12-14 01:29

    Your policy "MVG" could be the reason. Just comment

    <policy domain="coder" rights="none" pattern="MVG" />
    

    in /etc/ImageMagick/policy.xml and restart Apache server.

    0 讨论(0)
提交回复
热议问题