Scaling of images is slow af on first load

Enonic version: 6.4.1
OS: OSX

I’m creating a front page with three pretty heavy (full screen) images. Waiting for these three images to load kind of ruins the user experience.

Being the clever guy I think I am, I created a script that first loads a scaled 100x100 (I use wide if that has anything to say) version of the image (that looks ugly but resembles the real image). Once the page is loaded, I use some javascript to get the size of the viewport and require a new version of the same image, just in the correct resolution.

This actually works pretty well on subsequent loads, but the first load takes about 7-8 seconds. I’m assuming this is because you’re caching the image after the original resize / scale / filtering, which is fine - but I think 7-8 secs of rendering time really is too slow.

The reason the first load is important (or at least a bit important) is that since I use the viewport size, I’ll get several different requests. One for new iphones, another for older iphones, and n different versions for the different android phones available. Not to mention different laptop resolutions, or a potentially resized screen. I can’t run through all of these configurations to pre-populate the cache on each deploy (or every time I change one of the images), so that’s why it matters.

Am I doing something wrong here, or is this just the state of image resizing in Enonic these days?

How large are the images your are scaling from (originals), and how large are the images your are creating?

The originals are typically around 4000x3000, and the images I’m creating is window.outerWidth x window.outerHeight For my 15" Macbook Pro, the image requested is 2880 × 1620.

You can see the delay I’ve created by going to http://redesign.qa.posten.no. Notice that everything goes quite quickly on the second load for a given resolution.

First of all, you should set a max size for the images you are creating, and you need to consider retina screens. my image was 2800 px wide and huge.

Secondly - the reason it takes time is the original size: Hvor er pakken min.jpg (JPEG-bilde, 6979 × 3926 piksler)…
So simply upload more reasonably sized images if you need a faster response time for initial image creation :slight_smile:

Oh holy guacamole that is an enormous image. Sorry about that :smile:

Quick follow up question - when is the cache resized? When restarting the server? When redeploying the site? Never?

To my knowledge we’re using file caching for images - so never!
Unless you clean up the cache files I guess?

Remember this is completely safe and will never cause any conflicts or anything!

Beautiful :smile: reducing the size to 2880 worked wonders