From 40e839fd7e2f2b0d7dba268bce030a6e8fb437c1 Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Sat, 6 May 2023 07:09:41 -0400 Subject: [PATCH] image: Add a --frame-index option --- Userland/Utilities/image.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Userland/Utilities/image.cpp b/Userland/Utilities/image.cpp index 462e61d7c6..61d5fee05e 100644 --- a/Userland/Utilities/image.cpp +++ b/Userland/Utilities/image.cpp @@ -24,7 +24,10 @@ ErrorOr serenity_main(Main::Arguments arguments) StringView out_path; args_parser.add_option(out_path, "Path to output image file", "output", 'o', "FILE"); - bool ppm_ascii; + int frame_index = 0; + args_parser.add_option(frame_index, "Which frame of a multi-frame input image (0-based)", "frame-index", {}, "INDEX"); + + bool ppm_ascii = false; args_parser.add_option(ppm_ascii, "Convert to a PPM in ASCII", "ppm-ascii", {}); StringView assign_color_profile_path; @@ -52,7 +55,7 @@ ErrorOr serenity_main(Main::Arguments arguments) // This uses ImageDecoder instead of Bitmap::load_from_file() to have more control // over selecting a frame, access color profile data, and so on in the future. - auto frame = TRY(decoder->frame(0)).image; + auto frame = TRY(decoder->frame(frame_index)).image; Optional icc_data = TRY(decoder->icc_data()); RefPtr icc_file;