docker icon indicating copy to clipboard operation
docker copied to clipboard

ImagickException: FailedToExecuteCommand

Open junpet opened this issue 5 years ago • 5 comments

Steps to reproduce

  1. Enable previews for .pdf files in config.php
  2. Place .pdf file into your cloud.
  3. No previews.

Expected behaviour

Preview should be visible for .pdf files.

Actual behaviour

Preview is not visible for .pdf files. Errors can be found in the logs.

Server configuration

Operating system: I'm using Nextcloud in Docker, host machine is Debian GNU/Linux 10 (buster) Web server: What the official Docker latest image uses. I don't know Database: PostgreSQL 12.1 PHP version: 7.3.14 Nextcloud version: (see Nextcloud admin page) 18.0.0 Updated from an older Nextcloud/ownCloud or fresh install: Updated. Where did you install Nextcloud from: My English is not the best, I don't understand this question. I used Docker, last NC version was 17. I rarely used NC, but now I want to use it heavily. Signing status:

Signing status
No errors have been found.

List of activated apps:

App list
Enabled:
  - accessibility: 1.4.0
  - activity: 2.11.0
  - audioplayer: 2.9.0
  - bookmarks: 2.3.4
  - cloud_federation_api: 1.1.0
  - comments: 1.8.0
  - contacts: 3.1.8
  - dav: 1.14.0
  - deck: 0.8.0
  - federatedfilesharing: 1.8.0
  - federation: 1.8.0
  - files: 1.13.1
  - files_fulltextsearch_tesseract: 1.4.0
  - files_pdfviewer: 1.7.0
  - files_rightclick: 0.15.2
  - files_sharing: 1.10.1
  - files_trashbin: 1.8.0
  - files_versions: 1.11.0
  - files_videoplayer: 1.7.0
  - firstrunwizard: 2.7.0
  - logreader: 2.3.0
  - lookup_server_connector: 1.6.0
  - music: 0.12.1
  - nextcloud_announcements: 1.7.0
  - notes: 3.1.1
  - notifications: 2.6.0
  - oauth2: 1.6.0
  - password_policy: 1.8.0
  - photos: 1.0.0
  - previewgenerator: 2.2.0
  - privacy: 1.2.0
  - provisioning_api: 1.8.0
  - recommendations: 0.6.0
  - serverinfo: 1.8.0
  - settings: 1.0.0
  - sharebymail: 1.8.0
  - support: 1.1.0
  - systemtags: 1.8.0
  - tasks: 0.11.3
  - text: 2.0.0
  - theming: 1.9.0
  - twofactor_backupcodes: 1.7.0
  - updatenotification: 1.8.0
  - viewer: 1.2.0
  - workflowengine: 2.0.0
Disabled:
  - admin_audit
  - encryption
  - files_external
  - survey_client
  - unsplash
  - user_ldap

Nextcloud configuration:

Config report
{
    "system": {
        "htaccess.RewriteBase": "\/",
        "memcache.local": "\\OC\\Memcache\\APCu",
        "apps_paths": [
            {
                "path": "\/var\/www\/html\/apps",
                "url": "\/apps",
                "writable": false
            },
            {
                "path": "\/var\/www\/html\/custom_apps",
                "url": "\/custom_apps",
                "writable": true
            }
        ],
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "localhost",
            "*"
        ],
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "dbtype": "pgsql",
        "version": "18.0.0.10",
        "overwrite.cli.url": "http:\/\/localhost",
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbport": "",
        "dbtableprefix": "oc_",
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "installed": true,
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "maintenance": false,
        "theme": "",
        "loglevel": 2,
        "enable_previews": true,
        "preview_max_x": 4096,
        "preview_max_y": 4096,
        "preview_max_filesize_image": 50,
        "enabledPreviewProviders": [
            "OC\\Preview\\PNG",
            "OC\\Preview\\JPEG",
            "OC\\Preview\\GIF",
            "OC\\Preview\\HEIC",
            "OC\\Preview\\BMP",
            "OC\\Preview\\XBitmap",
            "OC\\Preview\\MP3",
            "OC\\Preview\\TXT",
            "OC\\Preview\\MarkDown",
            "OC\\Preview\\PDF"
        ]
    }
}

Are you using external storage, if yes which one: local/smb/sftp/... No. Are you using encryption: yes/no No. Are you using an external user-backend, if yes which one: LDAP/ActiveDirectory/Webdav/... No.

Client configuration

Browser: Firefox 72.0.2 (64-bit) Operating system: Microsoft Windows 10 Pro 10.0.18362 Build 18362

Logs

Web server error log

Web server error log
[core] Error: ImagickException: FailedToExecuteCommand `'gs' -sstdout=%stderr -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 '-sDEVICE=pngalpha' -dTextAlphaBits=4 -dGraphicsAlphaBits=4 '-r72x72' -dFirstPage=1 -dLastPage=1 '-sOutputFile=/tmp/magick-397ZDSa6kq509My%d' '-f/tmp/magick-397VO80Z51SJ9m1' '-f/tmp/magick-397tG2m4GScrfXt'' (1) @ error/pdf.c/InvokePDFDelegate/291 at <<closure>>

 0. /var/www/html/lib/private/Preview/Bitmap.php line 88
    Imagick->readimage("/var/www/html/d ... ]")
 1. /var/www/html/lib/private/Preview/Bitmap.php line 51
    OC\Preview\Bitmap->getResizedPreview("/var/www/html/d ... f", 4096, 4096)
 2. /var/www/html/lib/private/Preview/GeneratorHelper.php line 62
    OC\Preview\Bitmap->getThumbnail(OC\Files\Node\File {}, 4096, 4096)
 3. /var/www/html/lib/private/Preview/Generator.php line 205
    OC\Preview\GeneratorHelper->getThumbnail(OC\Preview\PDF {}, OC\Files\Node\File {}, 4096, 4096)
 4. /var/www/html/lib/private/Preview/Generator.php line 127
    OC\Preview\Generator->getMaxPreview(OC\Files\SimpleFS\SimpleFolder {}, OC\Files\Node\File {}, "application/pdf", "")
 5. /var/www/html/lib/private/PreviewManager.php line 185
    OC\Preview\Generator->getPreview(OC\Files\Node\File {}, 250, 250, true, "fill", "application/pdf")
 6. /var/www/html/core/Controller/PreviewController.php line 172
    OC\PreviewManager->getPreview(OC\Files\Node\File {}, 250, 250, true, "fill")
 7. /var/www/html/core/Controller/PreviewController.php line 144
    OC\Core\Controller\PreviewController->fetchPreview(OC\Files\Node\File {}, 250, 250, false, false, "fill")
 8. /var/www/html/lib/private/AppFramework/Http/Dispatcher.php line 170
    OC\Core\Controller\PreviewController->getPreviewByFileId(2490, 250, 250, false, false, "fill")
 9. /var/www/html/lib/private/AppFramework/Http/Dispatcher.php line 99
    OC\AppFramework\Http\Dispatcher->executeController(OC\Core\Controller\PreviewController {}, "getPreviewByFileId")
10. /var/www/html/lib/private/AppFramework/App.php line 125
    OC\AppFramework\Http\Dispatcher->dispatch(OC\Core\Controller\PreviewController {}, "getPreviewByFileId")
11. /var/www/html/lib/private/AppFramework/Routing/RouteActionHandler.php line 47
    OC\AppFramework\App::main("OC\\Core\\Controller\\PreviewController", "getPreviewByFileId", OC\AppFramework\ ... {}, {_route: "core.P ... "})
12. <<closure>>
    OC\AppFramework\Routing\RouteActionHandler->__invoke({_route: "core.P ... "})
13. /var/www/html/lib/private/Route/Router.php line 299
    call_user_func(OC\AppFramework\ ... {}, {_route: "core.P ... "})
14. /var/www/html/lib/base.php line 1008
    OC\Route\Router->match("/core/preview")
15. /var/www/html/index.php line 38
    OC::handleRequest()

GET /core/preview?fileId=2490&c=8eb29ee954f98c302dbfc4da66b563ee&x=250&y=250&forceIcon=0
from 91.220.172.105 by junpet at 2020-01-27T07:51:37+00:00

Nextcloud log (data/nextcloud.log)

Nextcloud log
{"reqId":"MptndJ55J6dUtHvv58LY","level":3,"time":"2020-01-28T17:23:03+00:00","remoteAddr":"134.255.41.33","user":"junpet","app":"core","method":"GET","url":"/core/preview?fileId=2490&c=8eb29ee954f98c302dbfc4da66b563ee&x=250&y=250&forceIcon=0","message":{"Exception":"ImagickException","Message":"FailedToExecuteCommand `'gs' -sstdout=%stderr -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 '-sDEVICE=pngalpha' -dTextAlphaBits=4 -dGraphicsAlphaBits=4 '-r72x72' -dFirstPage=1 -dLastPage=1 '-sOutputFile=/tmp/magick-654ud956DpNKhRC%d' '-f/tmp/magick-654z7PjFfBFoOC4' '-f/tmp/magick-654XUdlKVxkRtow'' (1) @ error/pdf.c/InvokePDFDelegate/291","Code":415,"Trace":[{"file":"/var/www/html/lib/private/Preview/Bitmap.php","line":88,"function":"readimage","class":"Imagick","type":"->","args":["/var/www/html/data/junpet/files/Documents/20191228122237.pdf[0]"]},{"file":"/var/www/html/lib/private/Preview/Bitmap.php","line":51,"function":"getResizedPreview","class":"OC\\Preview\\Bitmap","type":"->","args":["/var/www/html/data/junpet/files/Documents/20191228122237.pdf",4096,4096]},{"file":"/var/www/html/lib/private/Preview/GeneratorHelper.php","line":62,"function":"getThumbnail","class":"OC\\Preview\\Bitmap","type":"->","args":[{"__class__":"OC\\Files\\Node\\File"},4096,4096]},{"file":"/var/www/html/lib/private/Preview/Generator.php","line":205,"function":"getThumbnail","class":"OC\\Preview\\GeneratorHelper","type":"->","args":[{"__class__":"OC\\Preview\\PDF"},{"__class__":"OC\\Files\\Node\\File"},4096,4096]},{"file":"/var/www/html/lib/private/Preview/Generator.php","line":127,"function":"getMaxPreview","class":"OC\\Preview\\Generator","type":"->","args":[{"__class__":"OC\\Files\\SimpleFS\\SimpleFolder"},{"__class__":"OC\\Files\\Node\\File"},"application/pdf",""]},{"file":"/var/www/html/lib/private/PreviewManager.php","line":185,"function":"getPreview","class":"OC\\Preview\\Generator","type":"->","args":[{"__class__":"OC\\Files\\Node\\File"},250,250,true,"fill","application/pdf"]},{"file":"/var/www/html/core/Controller/PreviewController.php","line":172,"function":"getPreview","class":"OC\\PreviewManager","type":"->","args":[{"__class__":"OC\\Files\\Node\\File"},250,250,true,"fill"]},{"file":"/var/www/html/core/Controller/PreviewController.php","line":144,"function":"fetchPreview","class":"OC\\Core\\Controller\\PreviewController","type":"->","args":[{"__class__":"OC\\Files\\Node\\File"},250,250,false,false,"fill"]},{"file":"/var/www/html/lib/private/AppFramework/Http/Dispatcher.php","line":170,"function":"getPreviewByFileId","class":"OC\\Core\\Controller\\PreviewController","type":"->","args":[2490,250,250,false,false,"fill"]},{"file":"/var/www/html/lib/private/AppFramework/Http/Dispatcher.php","line":99,"function":"executeController","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[{"__class__":"OC\\Core\\Controller\\PreviewController"},"getPreviewByFileId"]},{"file":"/var/www/html/lib/private/AppFramework/App.php","line":125,"function":"dispatch","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[{"__class__":"OC\\Core\\Controller\\PreviewController"},"getPreviewByFileId"]},{"file":"/var/www/html/lib/private/AppFramework/Routing/RouteActionHandler.php","line":47,"function":"main","class":"OC\\AppFramework\\App","type":"::","args":["OC\\Core\\Controller\\PreviewController","getPreviewByFileId",{"__class__":"OC\\AppFramework\\DependencyInjection\\DIContainer"},{"_route":"core.Preview.getPreviewByFileId"}]},{"function":"__invoke","class":"OC\\AppFramework\\Routing\\RouteActionHandler","type":"->","args":[{"_route":"core.Preview.getPreviewByFileId"}]},{"file":"/var/www/html/lib/private/Route/Router.php","line":299,"function":"call_user_func","args":[{"__class__":"OC\\AppFramework\\Routing\\RouteActionHandler"},{"_route":"core.Preview.getPreviewByFileId"}]},{"file":"/var/www/html/lib/base.php","line":1008,"function":"match","class":"OC\\Route\\Router","type":"->","args":["/core/preview"]},{"file":"/var/www/html/index.php","line":38,"function":"handleRequest","class":"OC","type":"::","args":[]}],"File":"/var/www/html/lib/private/Preview/Bitmap.php","Line":88,"CustomMessage":"File: /junpet/files/Documents/20191228122237.pdf Imagick says:"},"userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0","version":"18.0.0.10"}

Browser log

Browser log
Content Security Policy: The page’s settings blocked the loading of a resource at inline (“script-src”). injected.js:1:7517
Content Security Policy: The page’s settings blocked the loading of a resource at inline (“script-src”). content.js:55:17
This page uses the non standard property “zoom”. Consider using calc() in the relevant property values, or using “transform” along with “transform-origin: 0 0”. addStylesClient.js:220:17
Proxying an event bus of version 1.1.2 with 0.2.1 ProxyBus.js:65:14
Handlebars is deprecated: please ship your own, this will be removed in Nextcloud 20 2 globals.js:66:15
Proxying an event bus of version 1.1.2 with 1.0.0 ProxyBus.js:67:14
Handlebars is deprecated: please ship your own, this will be removed in Nextcloud 20 3 globals.js:66:15
Handlebars is deprecated: please ship your own, this will be removed in Nextcloud 20 globals.js:66:15
Proxying an event bus of version 1.1.2 with 0.2.1 ProxyBus.js:65:14
Proxying an event bus of version 1.1.2 with 0.2.1 ProxyBus.js:65:14
Content Security Policy: The page’s settings blocked the loading of a resource at eval (“script-src”). getInferredName.js:6:19
Clipboard is deprecated: please ship your own, this will be removed in Nextcloud 20 globals.js:66:15
registerDetailView is deprecated! It will be removed in nextcloud 20. merged-index.js:7505:12
registerTabView is deprecated! It will be removed in nextcloud 20. merged-index.js:7493:12
Legacy tabs are deprecated! They will be removed in nextcloud 20. Tab.js:49:11
registerTabView is deprecated! It will be removed in nextcloud 20. merged-index.js:7493:12
Legacy tabs are deprecated! They will be removed in nextcloud 20. Tab.js:49:11
registerTabView is deprecated! It will be removed in nextcloud 20. merged-index.js:7493:12
Legacy tabs are deprecated! They will be removed in nextcloud 20. Tab.js:49:11
The humanFileSize library is deprecated! It will be removed in nextcloud 19. 9 globals.js:66:15

junpet avatar Jan 28 '20 17:01 junpet

Having the same issue. Using 18.0.1-apache image.

ghost avatar Feb 18 '20 18:02 ghost

same here 18.0.1

hartundweich avatar Mar 11 '20 09:03 hartundweich

this is because of a dependency on ImageMagick and ghost script which are not included by default in the latest image, how ever you can include them in the dokcer file provided in the .examples i had to install ghostscript and imagemagick to get the pdf preview to work. If it's a bug but am not sure it is i can make a PR of my modifications, let me know in case it can be helpful

el3ctrician avatar Apr 09 '20 10:04 el3ctrician

The nextcloud container in the nginx reverse proxy docker is invalid. If someone finds a solution, you can notify me at [email protected]

WhaleFell avatar Apr 16 '20 10:04 WhaleFell

Had the same issue. Just had to install ghostscript. The error message was freaking misleading.

Salamandar avatar Mar 07 '22 14:03 Salamandar