summaryrefslogtreecommitdiff
path: root/Userland/Utilities/image.cpp
diff options
context:
space:
mode:
authorNico Weber <thakis@chromium.org>2023-03-16 09:10:48 +0100
committerTim Flynn <trflynn89@pm.me>2023-03-16 10:18:44 -0400
commit0591aa1d9676b62427e374483ec5078613b4cc6c (patch)
tree8f218047595d9c06749b51f3d3bc1a411511519b /Userland/Utilities/image.cpp
parente05bb47134dbd0a835bac8b5db8b1579e38eeab9 (diff)
downloadserenity-0591aa1d9676b62427e374483ec5078613b4cc6c.zip
image: Add --assign-color-profile= flag
This allows assigning a color profile from a .icc file to the output. No pixel data conversion is taking place: the output will just contain this profile, so it better matches the image data already.
Diffstat (limited to 'Userland/Utilities/image.cpp')
-rw-r--r--Userland/Utilities/image.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/Userland/Utilities/image.cpp b/Userland/Utilities/image.cpp
index 1643b91443..6f99b916f0 100644
--- a/Userland/Utilities/image.cpp
+++ b/Userland/Utilities/image.cpp
@@ -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", {});
+ StringView assign_color_profile_path;
+ args_parser.add_option(assign_color_profile_path, "Load color profile from file and assign it to output image", "assign-color-profile", {}, "FILE");
+
bool strip_color_profile;
args_parser.add_option(strip_color_profile, "Do not write color profile to output", "strip-color-profile", {});
@@ -44,6 +47,12 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto frame = TRY(decoder->frame(0)).image;
Optional<ReadonlyBytes> icc_data = TRY(decoder->icc_data());
+ RefPtr<Core::MappedFile> icc_file;
+ if (!assign_color_profile_path.is_empty()) {
+ icc_file = TRY(Core::MappedFile::map(assign_color_profile_path));
+ icc_data = icc_file->bytes();
+ }
+
if (strip_color_profile)
icc_data.clear();