Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added webp as additional image format #642

Merged
merged 6 commits into from
Mar 16, 2024
Merged

Added webp as additional image format #642

merged 6 commits into from
Mar 16, 2024

Conversation

Photon89
Copy link
Member

@Photon89 Photon89 commented Dec 27, 2023

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 Photon89 linked an issue Dec 27, 2023 that may be closed by this pull request
@Photon89
Copy link
Member Author

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
Copy link
Member Author

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
Copy link

hsandt commented Feb 6, 2024

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
Copy link

hsandt commented Feb 7, 2024

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
Copy link
Member Author

Photon89 commented Feb 8, 2024

@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. 😄 Looks like it was a copy&paste error when making the change in the web editor.

@hsandt
Copy link

hsandt commented Mar 15, 2024

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
Copy link
Member Author

@DarthGandalf Any objections to merging this?

@DarthGandalf DarthGandalf merged commit 0966fc2 into master Mar 16, 2024
1 check passed
@DarthGandalf DarthGandalf deleted the webp-support branch March 16, 2024 09:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support webp image format
3 participants