craft-imageoptimize icon indicating copy to clipboard operation
craft-imageoptimize copied to clipboard

Sharp, Modes and Fit

Open smockensturm opened this issue 1 year ago • 0 comments

Question

We are using the Sharp Transform Method and the createOptimizedImages() function in a twig template. (Don't judge)

What is the best way to configure modes and fit? Am I missing something? Would be cool if we could pass that in with the variant.

Sometimes we want to 'cover' and sometimes we want to 'contain'

{
	'width': width,
	'useAspectRatio': ( height != null ) ? true : false,
	'aspectRatioX': width,
	'aspectRatioY': height,
	'retinaSizes': ['1'],
	'quality': 90,
	'format': 'jpg',
	'fit': 'contain'
}

Probably also background color. It is black at the moment. When forced to 'contain'.

smockensturm avatar Jun 22 '23 16:06 smockensturm