Skip to content

Commit 4358766

Browse files
LucasCholletnico
authored andcommitted
image: Add support for assigning from an internal color profile
This option is already supported in `--covert-to-color-profile`. And it allows invoking the tool this way: ``` $ image --assign-color-profile sRGB -o buggie-srgb.jpg buggie.png ```
1 parent 449de4f commit 4358766

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

Userland/Utilities/image.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ static ErrorOr<Options> parse_options(Main::Arguments arguments)
332332
args_parser.add_option(options.move_alpha_to_rgb, "Copy alpha channel to rgb, clear alpha", "move-alpha-to-rgb", {});
333333
args_parser.add_option(options.force_alpha, "Force alpha channel", "force-alpha", {});
334334
args_parser.add_option(options.strip_alpha, "Remove alpha channel", "strip-alpha", {});
335-
args_parser.add_option(options.assign_color_profile_path, "Load color profile from file and assign it to output image", "assign-color-profile", {}, "FILE");
335+
args_parser.add_option(options.assign_color_profile_path, "Load color profile and assign it to output image", "assign-color-profile", {}, "(FILE | \"sRGB\")");
336336
args_parser.add_option(options.convert_color_profile_path, "Load color profile and convert output image from current profile to loaded profile", "convert-to-color-profile", {}, "(FILE | \"sRGB\")");
337337
args_parser.add_option(options.strip_color_profile, "Do not write color profile to output", "strip-color-profile", {});
338338

@@ -420,11 +420,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
420420
if (options.to_bilevel.has_value())
421421
TRY(to_bilevel(image, options.to_bilevel.value()));
422422

423-
if (!options.assign_color_profile_path.is_empty()) {
424-
auto icc_file = TRY(Core::MappedFile::map(options.assign_color_profile_path));
425-
image.icc_data = icc_file->bytes();
426-
image.icc_handle = move(icc_file);
427-
}
423+
if (!options.assign_color_profile_path.is_empty())
424+
TRY(load_icc_profile(image, options.assign_color_profile_path));
428425

429426
if (!options.convert_color_profile_path.is_empty())
430427
TRY(convert_image_profile(image, options.convert_color_profile_path));

0 commit comments

Comments
 (0)