mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-04 05:20:30 +00:00
image: Add an option to tweak the quality of output JPEG
This commit is contained in:
parent
f3d15f53c9
commit
2e474e8c18
Notes:
sideshowbarker
2024-07-17 02:14:39 +09:00
Author: https://github.com/LucasChollet Commit: https://github.com/SerenityOS/serenity/commit/2e474e8c18 Pull-request: https://github.com/SerenityOS/serenity/pull/19741 Reviewed-by: https://github.com/awesomekling Reviewed-by: https://github.com/gmta ✅
1 changed files with 4 additions and 1 deletions
|
@ -49,6 +49,9 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
bool strip_color_profile = false;
|
||||
args_parser.add_option(strip_color_profile, "Do not write color profile to output", "strip-color-profile", {});
|
||||
|
||||
u8 quality = 75;
|
||||
args_parser.add_option(quality, "Quality used for the JPEG encoder, the default value is 75 on a scale from 0 to 100", "quality", {}, {});
|
||||
|
||||
args_parser.parse(arguments);
|
||||
|
||||
if (out_path.is_empty() ^ no_output) {
|
||||
|
@ -154,7 +157,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
TRY(Gfx::PortableFormatWriter::encode(*buffered_stream, *frame, { .format = format }));
|
||||
return 0;
|
||||
} else if (out_path.ends_with(".jpg"sv, CaseSensitivity::CaseInsensitive) || out_path.ends_with(".jpeg"sv, CaseSensitivity::CaseInsensitive)) {
|
||||
TRY(Gfx::JPEGWriter::encode(*buffered_stream, *frame));
|
||||
TRY(Gfx::JPEGWriter::encode(*buffered_stream, *frame, { .quality = quality }));
|
||||
return 0;
|
||||
} else if (out_path.ends_with(".qoi"sv, CaseSensitivity::CaseInsensitive)) {
|
||||
bytes = TRY(Gfx::QOIWriter::encode(*frame));
|
||||
|
|
Loading…
Reference in a new issue