Implemented Image compression rate?

BikeGremlin

Active member
It is nice that XF 2.3 has converts images to webp (apart from Avif which is still not widely supported, webp is probably the best option if you don't know in advance what types of images users will be uploading).

However, the compression rate is pretty low. I.e. you get some pretty big files after uploading.

I uploaded an image from my smartphone and it was cut to 600x800 (as configured by the max image setup in XenForo).
But the file size was almost 300 K.

When I saved that image from my forum (downloaded it) and gave it a go using squoosh.app, setting the export webp quality to 75 (out of 100) reduced the file size by 50% (to around 150 K), without destroying the quality.

It would be highly practical to have some better compression option built into XenForo - now that it has the webp conversion built in already.

Unless that already exists but I've missed it.

Relja
 
Upvote 1
This suggestion has been implemented. Votes are no longer accepted.
I think it’s 85

I’ve done some tests and found reasonable results even down as far as 35 with huge savings on disk space. Some discussion on Mattw’s site:

 
I suppose that the XF developers have voluntarily defined a high compression rate so as not to penalize certain forums whose photos occupy a significant part (notably the photography communities). 35% actually seems very aggressive to me. Maybe then 50/60 is a good compromise?
 
Last edited:
I suppose that the XF developers have voluntarily defined a high compression rate so as not to penalize certain forums whose photos occupy a significant part (notably the photography communities). 35% actually seems very aggressive to me. Maybe then 50 is a good compromise?
I think 50 is fine but worth testing on different types of images: portraits, wildlife flowers , landscapes, diagrams, black&white, still life, architecture etc.
 
Once the images have been optimized once, no amount of re-running the optimize tools (different from the screenshot above) will optimize them again as the quality would deteriorate with each successive run. Changing the rate will apply to new optimizations/uploads only.
 
You can set the compression rate in /src/config.php

$config['maxImageResizeQuality'] = 70;

Thank you - I managed to miss that (did try google and forum search).

That's great.

My forum is mostly tutorials and help with fixing bikes.
So the photos need to be clear enough to see nuts and bolts on close-ups, and to see what the bike generally looks like on "zoomed out" photos.

I've set the max size in pixels to 800x800 (that size seems to be OK for most stuff) - considering to reduce that to 700x700.

Regarding compression, would you say that 60 is generally OK (not making stuff too blurry)?

I will test it of course, but looking for feedback before doing that - to not do something obviously silly (to those who've already tested it).

EDIT:
Forum seemed to have missed to resize this photo - any idea of what I'm missing in the settings?

https://www.bikegremlin.net/threads...e-a-shifter-or-yours-is-broken.387/#post-1672
- That photo was uploaded recently - the image optimization to webp is enabled - with the default settings - but the image is .jpg.
I thought XenForo auto-converts all uploaded photos to Webp (definitely does so from my iphone).

LOL - I completely missed that the image is not stored locally. :)
XenForo works fine as far as I can tell. :)
 
Last edited:
Is this tool take the new rate in account?

View attachment 312728
I've rebuilt this:
1729494117144.webp

It takes a while, but the disk space has been reduced a lot.

EDIT: but I did it on a forum that was first on XF 2.2. The old attachments were optimised. On a forum that is on XF 2.3 from the start, nothing will happen with the existing attachments if image optimization is turned on from the start and the images are loaded in WebP. As Jeremy stated above.
 
XenForo practically makes image compression addons needless.

Sure, of uncompressed screenshots of mostly text, it is best to use PNG with reduced colour number, but for when you have no idea what and how users will upload, I suppose that a reasonably compressed Webp is the best least bad option.
 
Back
Top Bottom