shutter-project / shutter

Screenshot tool for Linux
https://shutter-project.org/
GNU General Public License v3.0
501 stars 35 forks source link

Added webp as additional image format #642

Closed Photon89 closed 3 months ago

Photon89 commented 6 months ago

Added webp as additional image format. Requires webp-pixbuf-loader as addition dependency. If the dependency is missing, webp is not listed among the available image formats.

Photon89 commented 6 months ago

Shutter calls

eval { $pixbuf->save($filename, $filetype, "tEXt::Software" => "Shutter", compression => $quality); };

the same as for png files, and reports the correct value for $quality, but screenshots taken with different quality don't differ in visual quality and file size. It looks like webp-pixbuf-loader is not correctly applying the quality setting. Or, very much possibly, I messed up something.

Photon89 commented 6 months ago

Worked it out now, the keyword for the quality setting is actually "quality" and not "compression" for webp. Now the quality setting is actually respected and reflected in visual quality and file size.

hsandt commented 4 months ago

Thanks, I tested it and it works.

I had already webp-pixbuf-loader installed, so I just had to make sure I closed the old Shutter instance and start this one (it showed some loading popup the first time), then went to Edit > Preferences > Image format and webp was indeed in the list.

I tried a comparison capture by repeating the same capture with PNG compression 9 and webp default quality 98, got a file size reduction factor between 3 and 4, excellent.

I just have to change my .desktop file to use this latest version of shutter until the PR gets merged and used for next release.

hsandt commented 4 months ago

Actually, I just checked my saved file quality and for a quality 98, I think it contains many artifacts (like a low-quality jpg).

image

Although Shutter will display a high quality picture in the app itself (it probably keeps a temp copy of the original screenshot just while running the app).

From here, Save as... png or webp will not improve quality, as it must save from the already low-quality image file.

Could you check that the quality parameter is properly applied once more? (and not reversed?)

EDIT: just checked the code and found that compression => $quality had been changed to quality => $quality in the PNG section in the last commit, instead of the webp section. I reverted the change in the PNG section and applied it in the webp section instead, and now webp quality setting seems to be applied correctly.

For PNG I could never see the impact of the compression (named quality in code when applied, but apparently it has been so since the beginning for convenience, although it's not semantically correct) as the output file size is the same, but it must have already been like this since the beginning - maybe it's just due to my pictures because so simple compression has no effect; anyway, unrelated to webp.

Could you apply said change on your PR and try it again?

Photon89 commented 4 months ago

@hsandt Thanks a lot for figuring it out! I should finally learn to use git branches from CLI instead of using the GitHub's web editor when working in a different branch. :smile: Looks like it was a copy&paste error when making the change in the web editor.

hsandt commented 3 months ago

I checked your last PR update, it's exactly the same as what I did so it must be working! Eager to see it merged!

Photon89 commented 3 months ago

@DarthGandalf Any objections to merging this?