Python Forum
PolicyError: not authorized `JRF-DEO.pdf' @ error/constitute.c/ReadImage/412 - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: PolicyError: not authorized `JRF-DEO.pdf' @ error/constitute.c/ReadImage/412 (/thread-15152.html)



PolicyError: not authorized `JRF-DEO.pdf' @ error/constitute.c/ReadImage/412 - bvdinesh - Jan-06-2019

Hi,

I am getting above error fro below code. This is I am running in Ubuntu and connected through SSH and Jupyter

from wand.image import Image as Img
with Img(filename="JRF-DEO.pdf", resolution=300) as img:
 img.compression_quality = 99
 img.save(filename="sample_scan.jpg")
---------------------------------------------------------------------------
PolicyError                               Traceback (most recent call last)
<ipython-input-27-5af7d0a73aff> in <module>()
      1 from wand.image import Image as Img
----> 2 with Img(filename="JRF-DEO.pdf", resolution=300) as img:
      3  img.compression_quality = 99
      4  img.save(filename="sample_scan.jpg")

/anaconda/envs/py35/lib/python3.5/site-packages/wand/image.py in __init__(self, image, blob, file, filename, format, width, height, depth, background, resolution, pseudo)
   4603                     self.read(blob=blob, resolution=resolution)
   4604                 elif filename is not None:
-> 4605                     self.read(filename=filename, resolution=resolution)
   4606                 # clear the wand format, otherwise any subsequent call to
   4607                 # MagickGetImageBlob will silently change the image to this

/anaconda/envs/py35/lib/python3.5/site-packages/wand/image.py in read(self, file, filename, blob, resolution)
   4894             r = library.MagickReadImage(self.wand, filename)
   4895         if not r:
-> 4896             self.raise_exception()
   4897 
   4898     def save(self, file=None, filename=None):

/anaconda/envs/py35/lib/python3.5/site-packages/wand/resource.py in raise_exception(self, stacklevel)
    220             warnings.warn(e, stacklevel=stacklevel + 1)
    221         elif isinstance(e, Exception):
--> 222             raise e
    223 
    224     def __enter__(self):

PolicyError: not authorized `JRF-DEO.pdf' @ error/constitute.c/ReadImage/412
Thanks


RE: PolicyError: not authorized `JRF-DEO.pdf' @ error/constitute.c/ReadImage/412 - bvdinesh - Jan-07-2019

updated image magic policy for pdf to read|write and restarted the system