Jump to content
a-ok

Resized images larger than original?

Recommended Posts

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?

190412416_Screenshot2019-10-11at20_57_34.thumb.jpg.f6ae822bed7adf70889ee8fe898e8472.jpg

Any thoughts on what I'm doing wrong?

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites
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 😉

Share this post


Link to post
Share on other sites

Anyone? Am I wrong in thinking that the variations would be smaller in filesize? The original is 2000px wide so there’s no upscale.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

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.

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...