kodfire
kodfire

Reputation: 1783

Is it possible to set quality in Image Intervention for WebP images?

I want to convert jpg to webp and set the quality to 50 (as an example). But the Image Intervention only supports the quality parameter only for jpg files.

quality (optional)

Define the quality of the encoded image optionally. Data ranging from 0 (poor quality, small file) to 100 (best quality, big file). Quality is only applied if you're encoding JPG format since PNG compression is lossless and does not affect image quality. Default: 90.

Is there any workaround?

Upvotes: 2

Views: 2445

Answers (2)

prst
prst

Reputation: 1

$webp = Image::make('public/foo.png')->encode('webp', 75); this only applies when you converting to .jpg from .png

Upvotes: 0

Luciano
Luciano

Reputation: 2196

As specified in docs: https://image.intervention.io/v2/api/encode You can encode the image in given format and given image quality.

$webp = Image::make('public/foo.png')->encode('webp', 75);

I did this today and worked as expected. Try to encode both qualities 80 and 100 and you will note the size difference, also a quality difference if you set it under 80

Upvotes: 1

Related Questions