# Large Thumbnails size in the files app

**URL:** <https://help.nextcloud.com/t/large-thumbnails-size-in-the-files-app/80525>\
**Category:** ℹ️ Support\
**Created:** [May 5, 2020, 12:37pm UTC](https://help.nextcloud.com/t/large-thumbnails-size-in-the-files-app/80525 "2020-05-05T12:37:08Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hutzi](https://help.nextcloud.com/letter_avatar/hutzi/32/6_22734026db12803ebb3e059622ac3534.png) [@Hutzi](https://help.nextcloud.com/u/Hutzi)\
**Post date:** [May 5, 2020, 12:37pm UTC](https://help.nextcloud.com/t/large-thumbnails-size-in-the-files-app/80525/1 "2020-05-05T12:37:08Z")

</div>

Nextcloud version _(eg, 18.0.2)_: 18.0.4  
Operating system and version _(eg, Ubuntu 20.04)_: Ubuntu 20.04  
Apache or nginx version _(eg, Apache 2.4.25)_: Nginx 1.18.0  
PHP version _(eg, 7.1)_: php-fpm 7.4.5

The issue you are facing:  
The file size of images in the files app is extremely big. I have a lot of folders with a Hugh amount of pictures inside. In slow networks its impossible to use because of the thumbnails need a lot of time to load. So I checked the source code…  
I found out that the files app uses pictures with a resolution of 1024x1024 and a file size of 1,2MB with for the small thumbnails. You can imagine that this couldn’t be a well experience with a slow network.

In the picture app everything is fine and its extremely fast. here the pictures are only 256x256 pixel with a size of 30 to 40KB.

I want that nextcloud is using the small previews in the files app

Is this the first time you’ve seen this error? _(Y/N)_: no

Steps to replicate it:

1. open files app
2. open folder with a lot of pictures
3. 

The output of your Nextcloud log in **Admin \> Logging** :  
no error

The output of your config.php file in `/path/to/nextcloud` (make sure you remove any identifiable information!):

```auto
<?php
$CONFIG = array (
  'instanceid' => 'xxx',
  'passwordsalt' => 'xxx',
  'secret' => 'xxx',
  'trusted_domains' => 
  array (
    0 => 'cloud.domain.tld',
  ),
  'datadirectory' => '/var/www/nextcloud/data',
  'dbtype' => 'mysql',
  'version' => '18.0.4.2',
  'overwrite.cli.url' => 'https://cloud.domain.tld',
  'dbname' => 'nextcloud_db',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'nextclouduser',
  'dbpassword' => 'xxx',
  'installed' => true,
  'updater.release.channel' => 'stable',
  'mail_smtpmode' => 'sendmail',
  'mail_sendmailmode' => 'smtp',
  'mail_smtpsecure' => 'ssl',
  'mail_from_address' => 'info',
  'mail_domain' => 'domain.tld',
  'mail_smtpauth' => 1,
  'mail_smtphost' => 'xxx',
  'mail_smtpport' => '465',
  'mail_smtpname' => 'xxx',
  'mail_smtppassword' => 'xxx',
  'mail_smtpauthtype' => 'LOGIN',
  'maintenance' => false,
  'theme' => '',
  'loglevel' => 2,
  'enabledPreviewProviders' => 
  array (
    0 => 'OC\\Preview\\PNG',
    1 => 'OC\\Preview\\JPEG',
    2 => 'OC\\Preview\\GIF',
    3 => 'OC\\Preview\\BMP',
    4 => 'OC\\Preview\\XBitmap',
    5 => 'OC\\Preview\\Movie',
    6 => 'OC\\Preview\\TXT',
    7 => 'OC\\Preview\\MarkDown',
    8 => 'OC\\Preview\\MSOffice2003',
    9 => 'OC\\Preview\\MSOffice2007',
    10 => 'OC\\Preview\\MSOfficeDoc',
    11 => 'OC\\Preview\\OpenDocument',
    12 => 'OC\\Preview\\PDF',
  ),
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'memcache.distributed' => '\\OC\\Memcache\\Redis',
  'filelocking.enabled' => true,
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'redis' => 
  array (
    'host' => '/var/run/redis/redis-server.sock',
    'port' => 0,
    'timeout' => 0.0,
  ),
);

```

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

```auto
PASTE HERE

```

---

<div class="post-metadata">

**Author:** ![gas85](https://help.nextcloud.com/user_avatar/help.nextcloud.com/gas85/32/7772_2.png) [@gas85](https://help.nextcloud.com/u/gas85)\
**Post date:** [May 5, 2020, 1:35pm UTC](https://help.nextcloud.com/t/large-thumbnails-size-in-the-files-app/80525/2 "2020-05-05T13:35:43Z")

</div>

You can generate smaller previews to safe time and bandwidth. Here I wrote small script to use in cron job [How to know if Preview Generator is working? - #6 by gas85](https://help.nextcloud.com/t/how-to-know-if-preview-generator-is-working/41072/6). And then:

> [@Previews / data size](https://help.nextcloud.com/t/previews-data-size/46990/2):
>
> Fist of all you have to adjust what kind of previews you would like to have. I have had the same problem and have to setup my config.php as following to have only FullHD previews maximal (default is 4096):

> [@Fairly new with nextcloud but preview folder has huge size](https://help.nextcloud.com/t/fairly-new-with-nextcloud-but-preview-folder-has-huge-size/64390/3):
>
> And remember, after you change the config, you have to regenerate previews again. Here is a good explanation how:

After that you will have nice small previews:

 ![grafik](https://help.nextcloud.com/uploads/default/original/3X/a/c/ac32edda8eeca57bb3acd7e620da9c4633c70af1.png)

But somehow you are right, I checked and there are still previews around 1 and 2 MB (not all of them), that is strange…

Seems that some previews were not pregenerated, then access to the file generates new file, but in png instead of jpg and it is quite big:

```auto
# du -ah preview/ | grep -E "png|jpg" | sort -h -r | head -n 20
2.9M	preview/806331/1536-1024-max.png
2.8M	preview/2823/1528-1044-max.png
2.7M	preview/2899/1527-1080-max.png
2.5M	preview/944452/1920-1080-max.png
2.4M	preview/2506474/1920-1080-max.png
2.4M	preview/1593491/1620-1080-max.png
2.3M	preview/333955/1660-1080-max.png
2.3M	preview/2503143/1190-893-max.png
2.1M	preview/1593493/1620-1080-max.png
2.0M	preview/2952315/1920-1080-max.png
2.0M	preview/2503144/1190-893-max.png
1.9M	preview/2790359/810-1080-max.png
1.9M	preview/1593492/1557-1080-max.png
1.8M	preview/2503151/1920-825-max.png
1.7M	preview/944586/1500-1000-max.png
1.7M	preview/942970/1500-1000-max.png
1.7M	preview/802162/1536-1024-max.png
1.7M	preview/330791/1500-1000-max.png
1.7M	preview/2503150/1190-893-max.png
1.7M	preview/1593629/1854-1080-max.png

```

and pre generated previews are in JPG, they are pretty ok:

```auto
# du -ah preview/ | grep "jpg" | sort -h -r | head -n 20
552K	preview/4588842/1919-1080-max.jpg
544K	preview/4587449/1734-1080-max.jpg
536K	preview/4588844/1919-1080-max.jpg
528K	preview/4588738/1919-1080-max.jpg
516K	preview/782965/1920-1080-max.jpg
512K	preview/72740/1920-1080-max.jpg
512K	preview/6190/1920-1080-max.jpg
512K	preview/4588762/1919-1080-max.jpg
512K	preview/4588693/1919-1080-max.jpg
500K	preview/4588735/1919-1080-max.jpg
500K	preview/2788724/1440-1080-max.jpg
500K	preview/1057309/1920-1080-max.jpg
496K	preview/4588731/1919-1080-max.jpg
496K	preview/4535176/1919-1080-max.jpg
496K	preview/2788709/1440-1080-max.jpg
488K	preview/12135/1920-1080-max.jpg
484K	preview/4588843/1919-1080-max.jpg
484K	preview/4586368/1919-1080-max.jpg
484K	preview/2782961/1440-1080-max.jpg
480K	preview/77330/1920-1080-max.jpg

```

---

<div class="post-metadata">

**Author:** ![Hutzi](https://help.nextcloud.com/letter_avatar/hutzi/32/6_22734026db12803ebb3e059622ac3534.png) [@Hutzi](https://help.nextcloud.com/u/Hutzi)\
**Post date:** [May 5, 2020, 3:39pm UTC](https://help.nextcloud.com/t/large-thumbnails-size-in-the-files-app/80525/3 "2020-05-05T15:39:01Z")

</div>

Thank you very much. Its seems to working. I followed the instructions and pregenerate the previews. The size of my preview folder decreased from 14GB to 2,8GB

But now nextcloud don’t create more previews of PDF files…

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

This solved my PDF Problem

```auto
# Open the file 
sudo nano /etc/ImageMagick-6/policy.xml

# find and edit the line
<policy domain="coder" rights="none" pattern="PDF" />
# to :
<policy domain="coder" rights="read|write" pattern="PDF" />

```

---

<div class="post-metadata">

**Author:** ![gas85](https://help.nextcloud.com/user_avatar/help.nextcloud.com/gas85/32/7772_2.png) [@gas85](https://help.nextcloud.com/u/gas85)\
**Post date:** [May 6, 2020, 7:02am UTC](https://help.nextcloud.com/t/large-thumbnails-size-in-the-files-app/80525/4 "2020-05-06T07:02:05Z")

</div>

Glad that it helps you!

> [@Hutzi](#):
>
> This solved my PDF Problem

You will meet the same problem with XPS, EPI and PS. [Old link](https://www.c-rieger.de/solution-for-imagickexception-in-nextcloud-log/) to how-to does not work any more, so please use new one from my wiki:  
[https://gas85.ddns.net/wiki/doku.php?id=howto:nextcloud&s[]=pdf#solutions\_for\_imagickexceptions\_in\_nextcloudlog](https://gas85.ddns.net/wiki/doku.php?id=howto:nextcloud&s%5B%5D=pdf#solutions_for_imagickexceptions_in_nextcloudlog)

## Solutions for ImagickExceptions in nextcloud.log

You are in trouble with previews and/or with thumbnails within your Nextcloud? You found errors like “ImagickException: not authorized…” in your Nextcloud logfile (/var/nc\_data/nextcloud.log)? Just follow these instructions in your terminal session (e.g. ssh) and solve these “Imagick” issues yourself: Error messages e.g.:

```auto
tail -f /var/nc_data/nextcloud.log | grep -i imagickexception
 
...
...ImagickException: not authorized `/upload_tmp/oc_tmp_zCg8T6-.d1539116135' @ error/constitute.c/ReadImage/412
...ImagickException: not authorized `/upload_tmp/oc_tmp_BiLdF7-.pdf' @ error/constitute.c/ReadImage/412
...

```

Solution 1:

```auto
sudo -s (or su -)
apt install ghostscript -y
ln -s /usr/local/bin/gs /usr/bin/gs
cp /etc/ImageMagick-6/policy.xml /etc/ImageMagick-6/policy.xml.bak
sed -i "s/rights\=\"none\" pattern\=\"PS\"/rights\=\"read\|write\" pattern\=\"PS\"/" /etc/ImageMagick-6/policy.xml
sed -i "s/rights\=\"none\" pattern\=\"EPI\"/rights\=\"read\|write\" pattern\=\"EPI\"/" /etc/ImageMagick-6/policy.xml
sed -i "s/rights\=\"none\" pattern\=\"PDF\"/rights\=\"read\|write\" pattern\=\"PDF\"/" /etc/ImageMagick-6/policy.xml
sed -i "s/rights\=\"none\" pattern\=\"XPS\"/rights\=\"read\|write\" pattern\=\"XPS\"/" /etc/ImageMagick-6/policy.xml
service php7.3-fpm restart && service nginx restart

```

---

<div class="post-metadata">

**Author:** ![Hutzi](https://help.nextcloud.com/letter_avatar/hutzi/32/6_22734026db12803ebb3e059622ac3534.png) [@Hutzi](https://help.nextcloud.com/u/Hutzi)\
**Post date:** [May 6, 2020, 8:45am UTC](https://help.nextcloud.com/t/large-thumbnails-size-in-the-files-app/80525/5 "2020-05-06T08:45:33Z")

</div>

Thanks, but I recognize that Nextcloud still isn’t using the 32x32 pictures for the preview in the files list. I don’t know why…

---

<div class="post-metadata">

**Author:** ![wwe](https://help.nextcloud.com/user_avatar/help.nextcloud.com/wwe/32/72963_2.png) [@wwe](https://help.nextcloud.com/u/wwe)\
**Post date:** [December 12, 2024, 6:46am UTC](https://help.nextcloud.com/t/large-thumbnails-size-in-the-files-app/80525/6 "2024-12-12T06:46:40Z")

</div>



---

<div class="post-metadata">

**Author:** ![wwe](https://help.nextcloud.com/user_avatar/help.nextcloud.com/wwe/32/72963_2.png) [@wwe](https://help.nextcloud.com/u/wwe)\
**Post date:** [December 12, 2024, 6:46am UTC](https://help.nextcloud.com/t/large-thumbnails-size-in-the-files-app/80525/7 "2024-12-12T06:46:41Z")

</div>


