HEIC/DNG Previews will not display no matter what I try (Linux/Apache)

I have spent weeks researching this issue and no solution anywhere has resolved it. Hopefully this will serve as a main support thread for all users experiencing this issue.

For the life of me I can’t get HEIC or DNG images to display a preview even though I have all installed requirements in my server.

Notice HEIC is available:

php -r 'phpinfo();' | grep HEIC
ImageMagick supported formats => 3FR, 3G2, 3GP, AAI, AI, APNG, ART, ARW, AVI, AVIF, AVS, BGR, BGRA, BGRO, BIE, BMP, BMP2, BMP3, BRF, CAL, CALS, CANVAS, CAPTION, CIN, CIP, CLIP, CMYK, CMYKA, CR2, CR3, CRW, CUR, CUT, DATA, DCM, DCR, DCX, DDS, DFONT, DJVU, DNG, DOT, DPX, DXT1, DXT5, EPDF, EPI, EPS, EPS2, EPS3, EPSF, EPSI, EPT, EPT2, EPT3, ERF, EXR, FAX, FILE, FITS, FRACTAL, FTP, FTS, G3, G4, GIF, GIF87, GRADIENT, GRAY, GRAYA, GROUP4, GV, H, HALD, HDR, HEIC, HISTOGRAM, HRZ, HTM, HTML, HTTP, HTTPS, ICB, ICO, ICON, IIQ, INFO, INLINE, IPL, ISOBRL, ISOBRL6, J2C, J2K, JBG, JBIG, JNG, JNX, JP2, JPC, JPE, JPEG, JPG, JPM, JPS, JPT, JSON, K25, KDC, LABEL, M2V, M4V, MAC, MAGICK, MAP, MASK, MAT, MATTE, MEF, MIFF, MKV, MNG, MONO, MOV, MP4, MPC, MPG, MRW, MSL, MSVG, MTV, MVG, NEF, NRW, NULL, ORF, OTB, OTF, PAL, PALM, PAM, PANGO, PATTERN, PBM, PCD, PCDS, PCL, PCT, PCX, PDB, PDF, PDFA, PEF, PES, PFA, PFB, PFM, PGM, PGX, PICON, PICT, PIX, PJPEG, PLASMA, PNG, PNG00, PNG24, PNG32, PNG48, PNG64, PNG8, PNM, POCKETMOD, PPM, PREVIEW, PS, PS2, PS3, PSB, PSD, PTIF, PWP, RADIAL-GRADIENT, RAF, RAS, RAW, RGB, RGBA, RGBO, RGF, RLA, RLE, RMF, RW2, SCR, SCT, SFW, SGI, SHTML, SIX, SIXEL, SPARSE-COLOR, SR2, SRF, STEGANO, SUN, SVG, SVGZ, TEXT, TGA, THUMBNAIL, TIFF, TIFF64, TILE, TIM, TTC, TTF, TXT, UBRL, UBRL6, UIL, UYVY, VDA, VICAR, VID, VIDEO, VIFF, VIPS, VST, WBMP, WEBM, WEBP, WMF, WMV, WMZ, WPG, X, X3F, XBM, XC, XCF, XPM, XPS, XV, XWD, YCbCr, YCbCrA, YUV
convert --version
Version: ImageMagick 6.9.11-60 Q16 x86_64 2021-01-25 https://imagemagick.org
Copyright: (C) 1999-2021 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC Modules OpenMP(4.5) 
Delegates (built-in): bzlib djvu fftw fontconfig freetype heic jbig jng jp2 jpeg lcms lqr ltdl lzma openexr pangocairo png tiff webp wmf x xml zlib

The Basics

  • Nextcloud Server version (e.g., 29.x.x):
    • Nextcloud Hub 10 (31.0.3)
  • Operating system and version (e.g., Ubuntu 24.04):
    • Ubuntu 22.04
  • Web server and version (e.g, Apache 2.4.25):
    • Server version: Apache/2.4.52 (Ubuntu)
  • Reverse proxy and version _(e.g. nginx 1.27.2)
    • NONE
  • PHP version (e.g, 8.3):
    • Version: 8.2.28
  • Is this the first time you’ve seen this error? (Yes / No):
    • No
  • When did this problem seem to first start?
    • Always existed but just started using HEIC/DNG format
  • Installation method (e.g. AlO, NCP, Bare Metal/Archive, etc.)
    • VM (ESXi)
  • Are you using CloudfIare, mod_security, or similar? (Yes / No)
    • No

Summary of the issue you are facing:

[…]

Steps to replicate it (hint: details matter!):

  1. Take photo using Apple RAW (HEIC)
  2. Wait until Nextcloud uploads it to the server using the mobile app.
  3. Upon viewing the thumbnails, photo has no preview and won’t display. Download is the only option.

Log entries

{
  "reqId": "y5bfpEVQsC5St50KXQ9i",
  "level": 3,
  "time": "2025-04-14T18:31:30+00:00",
  "remoteAddr": "192.168.143.44",
  "user": "REDACTED_USER",
  "app": "core",
  "method": "GET",
  "url": "/nextcloud/index.php/core/preview?fileId=1375213&x=1024&y=1024&a=1&mode=cover&forceIcon=0&mimeFallback=0",
  "message": "File: /REDACTED_USER/files/NFS FreeNAS/REDACTED_DIR/Photos/2025/04/25-04-13 13-33-51 9920.heic Imagick says:",
  "userAgent": "Mozilla/5.0 (iOS) Nextcloud-iOS/6.6.0",
  "version": "31.0.3.2",
  "exception": {
    "Exception": "ImagickException",
    "Message": "Failed to read the file",
    "Code": 1,
    "Trace": [
      {
        "file": "/var/www/html/nextcloud/lib/private/Preview/HEIC.php",
        "line": 100,
        "function": "pingImage",
        "class": "Imagick",
        "type": "->"
      },
      {
        "file": "/var/www/html/nextcloud/lib/private/Preview/HEIC.php",
        "line": 57,
        "function": "getResizedPreview",
        "class": "OC\\Preview\\HEIC",
        "type": "->"
      },
      {
        "file": "/var/www/html/nextcloud/lib/private/Preview/GeneratorHelper.php",
        "line": 44,
        "function": "getThumbnail",
        "class": "OC\\Preview\\HEIC",
        "type": "->"
      },
      {
        "file": "/var/www/html/nextcloud/lib/private/Preview/Generator.php",
        "line": 338,
        "function": "getThumbnail",
        "class": "OC\\Preview\\GeneratorHelper",
        "type": "->"
      },
      {
        "file": "/var/www/html/nextcloud/lib/private/Preview/Generator.php",
        "line": 314,
        "function": "generateProviderPreview",
        "class": "OC\\Preview\\Generator",
        "type": "->"
      },
      {
        "file": "/var/www/html/nextcloud/lib/private/Preview/Generator.php",
        "line": 120,
        "function": "getMaxPreview",
        "class": "OC\\Preview\\Generator",
        "type": "->"
      },
      {
        "file": "/var/www/html/nextcloud/lib/private/Preview/Generator.php",
        "line": 87,
        "function": "generatePreviews",
        "class": "OC\\Preview\\Generator",
        "type": "->"
      },
      {
        "file": "/var/www/html/nextcloud/lib/private/PreviewManager.php",
        "line": 167,
        "function": "getPreview",
        "class": "OC\\Preview\\Generator",
        "type": "->"
      },
      {
        "file": "/var/www/html/nextcloud/core/Controller/PreviewController.php",
        "line": 168,
        "function": "getPreview",
        "class": "OC\\PreviewManager",
        "type": "->"
      },
      {
        "file": "/var/www/html/nextcloud/core/Controller/PreviewController.php",
        "line": 127,
        "function": "fetchPreview",
        "class": "OC\\Core\\Controller\\PreviewController",
        "type": "->"
      },
      {
        "file": "/var/www/html/nextcloud/lib/private/AppFramework/Http/Dispatcher.php",
        "line": 200,
        "function": "getPreviewByFileId",
        "class": "OC\\Core\\Controller\\PreviewController",
        "type": "->"
      },
      {
        "file": "/var/www/html/nextcloud/lib/private/AppFramework/Http/Dispatcher.php",
        "line": 114,
        "function": "executeController",
        "class": "OC\\AppFramework\\Http\\Dispatcher",
        "type": "->"
      },
      {
        "file": "/var/www/html/nextcloud/lib/private/AppFramework/App.php",
        "line": 161,
        "function": "dispatch",
        "class": "OC\\AppFramework\\Http\\Dispatcher",
        "type": "->"
      },
      {
        "file": "/var/www/html/nextcloud/lib/private/Route/Router.php",
        "line": 307,
        "function": "main",
        "class": "OC\\AppFramework\\App",
        "type": "::"
      },
      {
        "file": "/var/www/html/nextcloud/lib/base.php",
        "line": 1025,
        "function": "match",
        "class": "OC\\Route\\Router",
        "type": "->"
      },
      {
        "file": "/var/www/html/nextcloud/index.php",
        "line": 24,
        "function": "handleRequest",
        "class": "OC",
        "type": "::"
      }
    ],
    "File": "/var/www/html/nextcloud/lib/private/Preview/HEIC.php",
    "Line": 100,
    "message": "File: /REDACTED_USER/files/NFS FreeNAS/REDACTED_DIR/Photos/2025/04/25-04-13 13-33-51 9920.heic Imagick says:",
    "exception": [],
    "CustomMessage": "File: /REDACTED_USER/files/NFS FreeNAS/REDACTED_DIR/Photos/2025/04/25-04-13 13-33-51 9920.heic Imagick says:"
  },
  "id": "67fd90cf0e262"
}


Web server / Reverse Proxy

The output of your Apache/nginx/system log in /var/log/____:

None

Configuration

Nextcloud

The output of occ config:list system or similar is best, but, if not possible, the contents of your config.php file from /path/to/nextcloud is fine (make sure to remove any identifiable information!):

<?php
$CONFIG = array (
  'instanceid' => 'REDACTED',
  'passwordsalt' => 'REDACTED',
  'secret' => 'REDACTED',
  'trusted_domains' => 
  array (
    0 => '192.168.143.5',
  ),
  'datadirectory' => '/var/www/html/nextcloud/data',
  'dbtype' => 'mysql',
  'version' => '31.0.3.2',
  'overwrite.cli.url' => 'https://192.168.143.5/nextcloud',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'REDACTED',
  'dbpassword' => 'REDACTED',
  'installed' => true,
  'htaccess.RewriteBase' => '/nextcloud',
  'trashbin_retention_obligation' => '10, 15',
  'filelocking.enabled' => 'true',
  'default_phone_region' => 'US',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'redis' => 
  array (
    'host' => '127.0.0.1',
    'port' => '6379',
    'timeout' => '0.0',
  ),
  'mail_smtpmode' => 'smtp',
  'mail_smtpsecure' => 'ssl',
  'mail_sendmailmode' => 'smtp',
  'mail_from_address' => 'REDACTED',
  'mail_domain' => 'gmail.com',
  'mail_smtpauth' => 1,
  'mail_smtpauthtype' => 'LOGIN',
  'mail_smtphost' => 'smtp.gmail.com',
  'mail_smtpport' => '465',
  'mail_smtpname' => 'REDACTED',
  'mail_smtppassword' => 'REDACTED',
  'maintenance' => false,
  'theme' => '',
  'loglevel' => 2,
  'app_install_overwrite' => 
  array (
    0 => 'analytics',
    1 => 'bbb',
  ),
  'memories.exiftool' => '/var/www/html/nextcloud/apps/memories/bin-ext/exiftool-amd64-glibc',
  'memories.vod.path' => '/var/www/html/nextcloud/apps/memories/bin-ext/go-vod-amd64',
  'maintenance_window_start' => 1,
);

I’m not sure how you can spend long time researching without finding many topics in this forum:

heic preview → both together Topics tagged heic & preview

what I’m completely missing from your config export is a relevant preview setting (other formats are required as well, depending on your config):

  'enable_previews' => true,
  'enabledPreviewProviders' => [
  'OC\\Preview\\HEIC',
],

beware: heic preview are disabled by default - don’t remember the reason - work through the topics github issue is referenced somewhere. but on the other end:

sounds more like permissions problem…

1 Like

Thanks for your reply @wwe. As I originally said, I did find similar issues but none of them had a clear answer or resolved my issue.

what I’m completely missing from your config export is a relevant preview setting (other formats are required as well, depending on your config):

How do I know this bit is needed? Can you tell based on my configuration attached on my original post?

beware: heic preview are disabled by default - don’t remember the reason - work through the topics github issue is referenced somewhere. but on the other end:

If so, I believe I have reached a dead end?

sounds more like permissions problem…

So in my troubleshooting steps, I tried a few different things found when searching and tried to run the preview generate command manually but didn’t have any luck. I suspect these logs to be associated with me attempting to run those commands.

I’m committed to resolving this and willing to put in as much work as needed. I’m not expecting the solution to be handed to me. Any suggestions on what to try next would be greatly appreciated and taken seriously.

consulting official docs helps: enabled preview providers in my eyes there preview providers block exists by default.

so please create a fresh set of logs for a successful preview generation e.g. jpg and failed one (e.g. upload this two file to a new directory and refresh the directory listing).

please review the topics, especially solved and Github issues related to HEIC - likely you will find some advises how to troubleshoot or maybe where to look for issues - post your steps and results.

In 2025, why does HEIC need to be enabled specifically?! Can someone post a direct link to the root issue?

iPhones have been using this format since 2017 according to wikipedia. Searching for nextcloud and heic returns lots of results, as so many people have been looking for a way to enable previews over multiple years. I cant find the ‘root issue’. Some posts suggest a security concern, but that doesn’t fit with the resolution I used, which is in this post -

I was able to fix my own instance with the solution @wwe provided, which was just a config edit. No installing extra packages/libs. This doesnt track with a security concern, the software is already installed. FYI I’m using the docker image ‘lscr.io/linuxserver/nextcloud:latest’ on unraid.

Is the docker image I’m using the issue, or are heic previews still turned off by defult? If so, why? Happy to read, link me to the issue if you can, don’t need to explain it here.

consulting official docs helps: enabled preview providers in my eyes there preview providers block exists by default.

After adding the HEIC preview provider, I am now able to at least view the file within Nextcloud. Before, it would simply download it.

so please create a fresh set of logs for a successful preview generation e.g. jpg and failed one (e.g. upload this two file to a new directory and refresh the directory listing).

I truncated the log file and added a HEIC and JPEG to the directory and refreshed it. No errors but if I do click on the HEIC file, I can view it but this appears in the log:

{"reqId":"gBE7fxUjP1NRCWbuMehT","level":3,"time":"2025-04-18T23:53:11+00:00","remoteAddr":"192.168.143.50","user":"junior466","app":"core","method":"GET","url":"/nextcloud/core/preview?fileId=1375965&x=32&y=32&mimeFallback=true&v=295ebd&a=0","message":"File: /junior466/files/Photos/test.heic Imagick says:","userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.3.1 Safari/605.1.15","version":"31.0.3.2","exception":{"Exception":"ImagickException","Message":"Failed to read the file","Code":1,"Trace":[{"file":"/var/www/html/nextcloud/lib/private/Preview/HEIC.php","line":100,"function":"pingImage","class":"Imagick","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/Preview/HEIC.php","line":57,"function":"getResizedPreview","class":"OC\\Preview\\HEIC","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/Preview/GeneratorHelper.php","line":44,"function":"getThumbnail","class":"OC\\Preview\\HEIC","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/Preview/Generator.php","line":338,"function":"getThumbnail","class":"OC\\Preview\\GeneratorHelper","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/Preview/Generator.php","line":314,"function":"generateProviderPreview","class":"OC\\Preview\\Generator","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/Preview/Generator.php","line":120,"function":"getMaxPreview","class":"OC\\Preview\\Generator","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/Preview/Generator.php","line":87,"function":"generatePreviews","class":"OC\\Preview\\Generator","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/PreviewManager.php","line":167,"function":"getPreview","class":"OC\\Preview\\Generator","type":"->"},{"file":"/var/www/html/nextcloud/core/Controller/PreviewController.php","line":168,"function":"getPreview","class":"OC\\PreviewManager","type":"->"},{"file":"/var/www/html/nextcloud/core/Controller/PreviewController.php","line":127,"function":"fetchPreview","class":"OC\\Core\\Controller\\PreviewController","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/AppFramework/Http/Dispatcher.php","line":200,"function":"getPreviewByFileId","class":"OC\\Core\\Controller\\PreviewController","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/AppFramework/Http/Dispatcher.php","line":114,"function":"executeController","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/AppFramework/App.php","line":161,"function":"dispatch","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/Route/Router.php","line":307,"function":"main","class":"OC\\AppFramework\\App","type":"::"},{"file":"/var/www/html/nextcloud/lib/base.php","line":1025,"function":"match","class":"OC\\Route\\Router","type":"->"},{"file":"/var/www/html/nextcloud/index.php","line":24,"function":"handleRequest","class":"OC","type":"::"}],"File":"/var/www/html/nextcloud/lib/private/Preview/HEIC.php","Line":100,"message":"File: /junior466/files/Photos/test.heic Imagick says:","exception":[],"CustomMessage":"File: /junior466/files/Photos/test.heic Imagick says:"},"id":"6802e5eb5affb"}

Getting a bit closer now. The error “failed to read the file” turned out to be I needed to upgrade libheif to the latest version which includes improvements in reading files created by iOS18.

Still no previews but no more errors in the logs. Will keep trying and update this thread if I find a solution. Hopefully this helps someone out there.

1 Like