Optimizing preview generation results in NO previews at all for many files

I followed the recommended configuration in this very good article:

After making those config changes I deleted all existing previews (files and database entries) and started the initial preview generation using the occ command.

Very good results (much faster generation, way less storage needed), BUT:

  • before optimization: roughly 14.000 elements (folders containing individual preview files in the preview folder)
  • after optimization: roughly only 6.000 elements

Result: for many many files (14k-6k = almost 8k) there´s no preview at all, doesn´t matter which size. They´re also not created on the fly. Very annoying!

How can I tweak the optimization settings to create previews for all files (again)?

1 Like

To answer this question, you need to identify the files for which now previews are generated anymore. Are they all JPG files, or of which type they are? You might also find log entries giving your more insight about why some previews haven’t been generated.

BTW, it might always be a good idea to provide some more information about your environment, OS, Nextcloud version etc. :wink:

1 Like

Affected files:

  • what I see after manually checking hundreds of them: mostly JPG files (few HEIC).
  • for few of them there are log entries, usually saying “too large”
    (“ImagickException: width or height exceeds limit `/usr/data/nextcloud/data/user/files/xxx/IMG_1234.HEIC’ @ error/cache.c/OpenPixelCache/3912”: typically panorama shots with e.g. 16374 x 3756 pixel where limit is 2048 pixel so those are understandable error log entries).

Long story short:

  • while writing this post I reran “occ files:scan-app-data” and immediately (after finished within 20 minutes) all the missing previews where there.
  • So files were existing but not indexed in the database yet, seems the “occ preview:generate-all” didn´t work/finish properly. Table “nc_filecache” is now significantly bigger than before containing all the appdata_xxx/preview files.

Therefore I reran both (first generate-all and second scan-app-data) occ commands again two times just to make sure; now it looks good again. So the optimization wasn´t the root cause, I bet on one/both occ commands not finishing cleanly.


This might be related to the 'preview_max_filesize_image' => 50, parameter which skips the preview generation for all image files greater than the given size.

previews for HEIC files are on generated if the underlying imagick program supports the format. See the following posting for further details:

1 Like