filebrowser icon indicating copy to clipboard operation
filebrowser copied to clipboard

File Browser generates thumbnails for ludicrously large images

Open MHanak1 opened this issue 1 year ago β€’ 4 comments

Description

File Browser generates thumbnails for ludicrously large images

Expected behaviour

File Browser should not generate thumbnails for ludicrously large images

What is happening instead?

The thumbnails are being generated causing significant resource usage

Additional context

https://files.mhanak.net/api/public/dl/xlDIQwBq?inline=true

(if this link ever rots: this is a screenshot showing 97% CPU usage on all 28 cores, all 32 gigs of ram used with 8 gigs of swap filled)

How to reproduce?

download and unzip this file, and upload this image to your server: https://files.mhanak.net/share/I0CqtjdX open the directory with the image you will notice your memory usage spike to around 40GB

Files

the files failed to upload on github, so here are share links to them and i hope they don't rot too fast screenshot of the issue: https://files.mhanak.net/api/public/dl/xlDIQwBq?inline=true example large image: https://files.mhanak.net/share/I0CqtjdX (zipped to prevent previews from generating)

MHanak1 avatar May 01 '25 22:05 MHanak1

Itβ€˜s weird. As I know, most of the thumbnails are extracted directly from the exif part of .jpg files. If there is no exif, then it will generate the thumbnails. I think this problem was fixed several years ago: https://github.com/filebrowser/filebrowser/pull/1234

niubility000 avatar May 15 '25 05:05 niubility000

While being of a small file size, the image is actually 65500 x 64860 pixels large (4248 megapixels). The file does not have an embedded EXIF thumbnail, so filebrowser tries to generate one from the image. For me, RAM and CPU usage is consistent with that incredibly large image.

While this isn't a bug per se, I think we should find a way to not hog the servers ressources as this might severly impact the user. @hacdias Labeling this as bug, perhaps we can add a workaround like only creating thumbnails for images smaller than X megapixels?

jniggemann avatar Jun 14 '25 12:06 jniggemann

Yes, I think it's fine to not generate a thumbnail if: the file does not have an embedded EXIF thumbnail and the image is larger than X MP.

hacdias avatar Jun 14 '25 13:06 hacdias

How open are we to go with govips. I have tested with govips implementation and it works well for me.

did not use more than 500mb ram and 40% cpu on laptop with 4 cores 8 threads. for the above gobber.jpg pic

jagadam97 avatar Jul 07 '25 01:07 jagadam97