Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no pdf thumbnail generation Imagick #3373

Closed
mhsdesign opened this issue Jul 5, 2021 · 2 comments
Closed

no pdf thumbnail generation Imagick #3373

mhsdesign opened this issue Jul 5, 2021 · 2 comments

Comments

@mhsdesign
Copy link
Member

mhsdesign commented Jul 5, 2021

Description

i have an issue with pdf thumbnail generation on Neos 7.1 with Imagick.

Steps to Reproduce

  1. install neos demo
  2. go to the media module
  3. find the pdf neos-1.2.0-deps-graph.pdf

Expected behavior

you see a thumbnail

Actual behavior

you see an endless loading spinner:
image

Digging further:

when you inspect (dev tools) the loading spinner, and search for the img tag which should display the thumbnail, and follow the source (something like: http://my-cool.site/media/thumbnail/4b1f64bb-14d9-47fc-98e9-4a4ae6161faa), you will get a 500 error:




Unable to generate thumbnail for the given document (filename: neos-1.2.0-deps-graph.pdf, SHA1: c0e682d8e660aa3f102d6269915c6a13fa69ed3e)

Exception Code1433109652
Exception TypeNeos\Media\Exception\NoThumbnailAvailableException
Log Reference20210705210423f47a6e
Thrown in FileData/Temporary/Development/Cache/Code/Flow_Object_Classes/Neos_Media_Domain_Model_ThumbnailGenerator_DocumentThumbnailGenerator.php
Line95
Original FilePackages/Application/Neos.Media/Classes/Domain/Model/ThumbnailGenerator/DocumentThumbnailGenerator.php

Nested Exception

attempt to perform an operation not allowed by the security policy `PDF' @ error/constitute.c/IsCoderAuthorized/408

Exception Code499
Exception TypeImagickException
Thrown in FileData/Temporary/Development/Cache/Code/Flow_Object_Classes/Neos_Media_Domain_Model_ThumbnailGenerator_DocumentThumbnailGenerator.php
Line63
Original FilePackages/Application/Neos.Media/Classes/Domain/Model/ThumbnailGenerator/DocumentThumbnailGenerator.php



image

More detail:

This happens with all pdfs. Also newly uploaded.
The detail view works fine:

image

Affected Versions

The 'default' driver GD (when i comment out Neos -> Flow -> Imagine) seems to work. GD doesnt create a thumbnail, and you will see a pdf icon svg (/_Resources/Static/Packages/Neos.Media/IconSets/vivid/pdf.svg):
image

To my knowledge:

Neos: 7.1

Flow: 7.1

@PRGfx
Copy link
Contributor

PRGfx commented Jul 6, 2021

The nested exception with the security policy gives a clear hint on the ImageMagick policy.xml (https://imagemagick.org/script/security-policy.php) which by default forbids actions on PDF files.
You would need to adjust the configuration in your ImageMagick Policy to something like <policy domain="coder" rights="read|write" pattern="PDF" />.
(The details-view is a JS PDF viewer)

@mhsdesign
Copy link
Member Author

Oops thanks it worked @PRGfx !

I only needed to create a config file, where ImageMagick expects it: $HOME/.config/ImageMagick/policy.xml
(One can also set the environment variable MAGICK_CONFIGURE_PATH to the directory where your policy.xml is in.)
And added in this policy.xml your snippet:

<policy domain="coder" rights="read|write" pattern="PDF" />.

(This policy.xml will now override the default one in /etc/ImageMagick-6/policy.xml)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants