XF2 Image Optimization

PumpinIron

Well-known member
One of the issues I am having with my forum is that people are uploading lots of high resolution photos without optimizing them first. Because of this, it's causing the disk space on my server to fill up faster than I'd like. Even if I put a data cap on the size of the image that can be uploaded, this just frustrates members, because then they get error messages about their image being too big, but they usually aren't savvy enough to figure out how to resize it.

I'm really shocked that something like this isn't built into XenForo by default. For instance, I know if you post a 8Mb photo to Facebook, they optimize it as it's being uploaded (granted they REALLY degrade the quality).

I know @ThemeHouse makes an image optimizer plugin that takes advantage of Kraken.io, but I'm just trying to figure out the best way to go about this.

The ideal goal here would be that I could optimize every photo on my forum currently, and that going forward, every time someone uploaded a file, it would optimize that image as well.

I apologize in advance if this is in the wrong sub-forum. I wasn't 100% certain where to post it.
 
XF already does that and had done since the start.

Points 6 and 7 here: https://xenforo.com/community/threads/frequently-asked-questions.5183/#post-180445

Maybe I'm just misunderstanding, but point 6 says:

Server-side file size (KB) resizing is not supported. Any files which are larger than the maximum size specified in the ACP -> Options -> Attachments: Maximum Attachment File Size (KB) will be rejected.

So that means XF can't resize an image that a forum member is uploading, right? They'd have to upload an already optimized image?

EDIT: Nevermind, I think I get it.

So then what (if anything) is there to gain from something like kraken.io? Just further reducing the file size?
 
So then what (if anything) is there to gain from something like kraken.io? Just further reducing the file size?

When you upload the image XenForo essentially just reduces the number of pixels, our image optimizer add-on runs the image through Kraken after this happens. Kraken uses an algorithm to further reduce the file size without losing any quality on the images (there is a separate "lossy" option as well that will reduce quality a bit, but also reduce filesize further). The amount of space you'll save entirely depends on the image, if there are large areas that are the same color you'll see a larger reduction. As an example:

Original image (389KB):
original.webp
Optimized (215KB):
optimized.webp

(Not sure what XF's settings are for reducing filesize here, so I've attached both of these in a zip as well)
Kraken is a pretty great service, you can try their free interface for images less than 1 MB to see some examples with your own images as well. In addition to reducing filesize it'll also convert any jpg images to a progressive jpg format that will have browsers download the image in a way that allows them to show a lower quality image earlier while the rest of the detail is loaded (more details on that here: https://support.kraken.io/general/what-is-progressive-jpeg-and-does-krakenio-support-it
 

Attachments

Last edited:
When you upload the image XenForo essentially just reduces the number of pixels, our image optimizer add-on runs the image through Kraken after this happens. Kraken uses an algorithm to further reduce the file size without losing any quality on the images (there is a separate "lossy" option as well that will reduce quality a bit, but also reduce filesize further). The amount of space you'll save entirely depends on the image, if there are large areas that are the same color you'll see a larger reduction. As an example:

Original image (389KB):
View attachment 184038
Optimized (215KB):
View attachment 184039

(Not sure what XF's settings are for reducing filesize here, so I've attached both of these in a zip as well)
Kraken is a pretty great service, you can try their free interface for images less than 1 MB to see some examples with your own images as well. In addition to reducing filesize it'll also convert any jpg images to a progressive jpg format that will have browsers download the image in a way that allows them to show a lower quality image earlier while the rest of the detail is loaded (more details on that here: https://support.kraken.io/general/what-is-progressive-jpeg-and-does-krakenio-support-it


So with your optimizer, it optimizes images on-the-fly as someone is uploading them?

I want to make sure that it isn't storing the original version AND the optimized version on my server, because then I would have two images on my server, taking up even more disk space.

In addition, I'm assuming the image it optimizes is hosted on MY server, and not in Kraken's cloud server or somewhere else... right?

Just trying to cover all the bases before I give it a try!
 
So with your optimizer, it optimizes images on-the-fly as someone is uploading them?

This is an option, it can either run the parser while the user is uploading the image, which will cause uploading images to take a bit longer or it can be passed off onto a cron and handled after the post has already been made.

I want to make sure that it isn't storing the original version AND the optimized version on my server, because then I would have two images on my server, taking up even more disk space.

After the optimization completes the original image is removed from the server. The XF1 version has the option to keep the original stored as well, but I believe we removed this from the xf2 version as there was a lot of confusion around this option.

In addition, I'm assuming the image it optimizes is hosted on MY server, and not in Kraken's cloud server or somewhere else... right?

Right, once it optimizes the image is downloaded from Kraken's servers onto your own server, so it can be uninstalled at any time without causing any issues (other than new images not being optimized, of course)
 
This is an option, it can either run the parser while the user is uploading the image, which will cause uploading images to take a bit longer or it can be passed off onto a cron and handled after the post has already been made.



After the optimization completes the original image is removed from the server. The XF1 version has the option to keep the original stored as well, but I believe we removed this from the xf2 version as there was a lot of confusion around this option.



Right, once it optimizes the image is downloaded from Kraken's servers onto your own server, so it can be uninstalled at any time without causing any issues (other than new images not being optimized, of course)

Cool, that is exactly what I'm looking for then.

Now all I have to do is wait until you guys release UI.X Classic so I can upgrade to XenForo 2... Haha! I've been waiting for ThemeHouse to release it for almost a year now. It's the only thing holding me back from upgrading to XF2, since my forum is currently running UI.X on XF1, and I want to keep the same look as much as possible.
 
My understanding for XF1.5 is that if we directly (file level from shell) optimise the image files within data/attachments then it causes problems due to checksum being different between DB and file. Is this still the case for XF2? Eg. we cannot just run a system cron for image optimisation on files within XF.
 
My understanding for XF1.5 is that if we directly (file level from shell) optimise the image files within data/attachments then it causes problems due to checksum being different between DB and file. Is this still the case for XF2? Eg. we cannot just run a system cron for image optimisation on files within XF.

I'm wondering this as well. @Mike @Chris D
 
Top Bottom