2

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?

kodfire
  • 1,612
  • 3
  • 18
  • 57

2 Answers2

1

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

Luciano
  • 2,052
  • 1
  • 16
  • 26
  • Have you read the `quality` section? You mean they have written something wrong there? I tested the one you mentioned, no luck! – kodfire Feb 14 '22 at 07:20
0

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

prst
  • 1
  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Apr 28 '23 at 13:55