haiwen / seahub

The web end of seafile server.
seafile.com
Other
527 stars 367 forks source link

Thumbnails for JPGs are served in PNG format #3999

Open MarcusRiemer opened 5 years ago

MarcusRiemer commented 5 years ago

Thumbnails that are fetched via URLs like https://seafile/thumbnail/fe2514c3-ef76-4f92-8f78-175e5034a688/192/IMG_20190102_084007.jpg seem to be always encoded as PNG. For photos this often adds a substantial overhead. I downloaded an example thumbnail (thumb.jpg.png) and converted it to JPG via magick convert thumb.jpg.png thumb.jpg. For a "typical" photo from an Android smartphone this results in the following sizes:

marcus@rechenknecht:~/d/seafile-test >>> magick convert thumb.jpg.png thumb.jpg
marcus@rechenknecht:~/d/seafile-test >>> du *
16K thumb.jpg
52K thumb.jpg.png

Would it be possible to serve the thumbnails using the same encoding that they had originally?

ao8833 commented 5 years ago

Not exactly what you wanted but when you add

THUMBNAIL_EXTENSION = 'JPEG'

to conf/seahub_settings.py all thumbnails get served as JPEGs. You might want to delete the contents of seahub-data/thumbnail after that.

poofeg commented 3 years ago

@MarcusRiemer @ao8833, I suggest using the following setting:

THUMBNAIL_EXTENSION = 'webp'

This will preserve the transparency of the PNG and reduce the size of thumbnails. WEBP is now supported by all modern browsers:

draeath commented 3 years ago

@poofeg seafile doesn't (currently) support webp in the WebUI it seems - when you browse to a webp image you get the following error:

Online view is not applicable to this file format

Might also need to add this to a whitelist somewhere. Perhaps FILEEXT_ICON_MAP{} in seahub/base/templatetags/seahub_tags.py?

(I'm using Pro 7.1.14)

I have opened #4867 which should probably be addressed before serving thumbnails as webp.

poofeg commented 3 years ago

@draeath, I'm using Seafile 8.0.2, THUMBNAIL_EXTENSION = 'webp' works without any problems.