a-ok Posted October 11, 2019 Share Posted October 11, 2019 I'm resizing my images for img srcset using a helper function: function getSrcsetImages($image, $variations, $sizes) { $srcset = array(); if (empty($variations)) { $srcsetSizes = array(100, 200, 300, 400, 500, 640, 750, 828, 1024, 1125, 1242, 1280, 1400, 1500, 1600, 1700, 1800, 1920); } else { $srcsetSizes = explode(", ", $variations); } foreach ($srcsetSizes as $s) { if ($s <= ceil($image->width())) { $srcset[] = $image->width($s)->url() . " {$s}w"; } } $srcset = implode(", ", $srcset); echo "src=\"{$image->url}\" data-srcset=\"{$srcset}\" sizes=\"{$sizes}\""; } <img <?php getSrcsetImages($image, null, "auto"); ?> class="--lazy" /> This works in theory but in my assets folder why are the variations, on average, larger than the original? Feels like I should just use one image at this point? Any thoughts on what I'm doing wrong? Link to comment Share on other sites More sharing options...
dragan Posted October 12, 2019 Share Posted October 12, 2019 Are you using image compression at all? Are you seriously going to use 18 variations in a live site? Or is this just a test? Link to comment Share on other sites More sharing options...
a-ok Posted October 12, 2019 Author Share Posted October 12, 2019 2 hours ago, dragan said: Are you using image compression at all? Are you seriously going to use 18 variations in a live site? Or is this just a test? Not to my knowledge. I have this in my config.php file: $config->imageSizerOptions('sharpening', 'none'); $config->imageSizerOptions('quality', 100); $config->imageSizerOptions('defaultGamma', -1); And yes just a test ? Link to comment Share on other sites More sharing options...
a-ok Posted October 12, 2019 Author Share Posted October 12, 2019 Anyone? Am I wrong in thinking that the variations would be smaller in filesize? The original is 2000px wide so there’s no upscale. Link to comment Share on other sites More sharing options...
Robin S Posted October 13, 2019 Share Posted October 13, 2019 16 hours ago, a-ok said: $config->imageSizerOptions('quality', 100); It all depends on how your original image was created. Was it saved at maximum quality? Was it passed through some sort of optimisation process/service (TinyJPG, CompressOrDie, etc) that compressed the image and reduced the filesize? Your PW resizer settings are asking for maximum quality, minimum compression, and therefore you can expect relatively large filesizes. And the PW resizer is not going to produce filesizes as small a specialised optimisation service, particularly one that you customise the settings of per image. Link to comment Share on other sites More sharing options...
a-ok Posted October 13, 2019 Author Share Posted October 13, 2019 Thanks, @Robin S The original is saved at JPEG quality 8 in Photoshop. Anything less than 100 in PW, in my experience, messes with the colours so always have to keep it at 100. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now