1

I'm using the gem gem 'rmagick', '3.1.0' and i am trying to upload a PDF, convert each pages to a jpg and ship the jpgs off to S3. It is currently working on my local environment and my staging server, but not working on my production server. I can't tell right now that anything is different between my staging and production servers.

The code being called:

images = Magick::Image.from_blob(params[:set_list_item][:attachment].read)

The error i'm receiving:

Magick::ImageMagickError not authorized `/tmp/magick-o0O927WR' @ error/constitute.c/ReadImage/454

Any help or insight is greatly appreciated. I have tried some of the suggestions by changing the policies for imagemagick to read|write for PDF and HTTPS but that didn't solve the issue.

ryanpitts1
  • 862
  • 1
  • 16
  • 33
  • Do you have permissions to write to /tmp? Do you have Ghostscript installed? One other possibility is that you need to modify your policy.xml for PDF access. See https://stackoverflow.com/questions/52861946/imagemagick-not-authorized-to-convert-pdf-to-an-image/52863413#52863413 – fmw42 May 16 '19 at 02:54
  • Permissions are the same between the staging and production servers for the `/tmp` directory and i do have Ghostscript installed. I thought changing the policy file would help but even change PDF policy to `read|write` doesn't help, unfortunately. – ryanpitts1 May 16 '19 at 02:58
  • Try putting the full path to Ghostscript in the delegates.xml file for PDF where it says `command=""gs"`. Put the path before the `gs`, which is Ghostscript. – fmw42 May 16 '19 at 05:00

1 Answers1

3

Open the file policy.xml from location /etc/ImageMagick-6/policy.xml and change the rights

$ sudo vi /etc/ImageMagick-6/policy.xml

Not sure why this worked, and thought I had tried it before but it's working now. I changed both the following lines from rights="none" to rights="read|write":

<policy domain="coder" rights="read|write" pattern="PS" />
<policy domain="coder" rights="read|write" pattern="PDF" />
rmlockerd
  • 3,776
  • 2
  • 15
  • 25
ryanpitts1
  • 862
  • 1
  • 16
  • 33