image: Add --strip-color-profile flag

With this flag, no color profile is copied from the source image
to the destination image.
This commit is contained in:
Nico Weber 2023-03-16 09:02:31 +01:00 committed by Tim Flynn
parent 14581e98ad
commit e05bb47134
Notes: sideshowbarker 2024-07-17 03:25:24 +09:00

View file

@ -26,6 +26,9 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
bool ppm_ascii;
args_parser.add_option(ppm_ascii, "Convert to a PPM in ASCII", "ppm-ascii", {});
bool strip_color_profile;
args_parser.add_option(strip_color_profile, "Do not write color profile to output", "strip-color-profile", {});
args_parser.parse(arguments);
if (out_path.is_empty()) {
@ -41,6 +44,9 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto frame = TRY(decoder->frame(0)).image;
Optional<ReadonlyBytes> icc_data = TRY(decoder->icc_data());
if (strip_color_profile)
icc_data.clear();
ByteBuffer bytes;
if (out_path.ends_with(".bmp"sv, CaseSensitivity::CaseInsensitive)) {
bytes = TRY(Gfx::BMPWriter::encode(*frame, { .icc_data = icc_data }));