Skip to content

Commit df83fb4

Browse files
committed
animation: Add --frame-duration-ms flag
This allows overriding the frame duration, which is especially useful when making an animation out of several single-frame images.
1 parent b35cd60 commit df83fb4

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Userland/Utilities/animation.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ struct Options {
1818
StringView out_path;
1919
bool write_full_frames { false };
2020
Gfx::AnimationWriter::AllowInterFrameCompression allow_inter_frame_compression { Gfx::AnimationWriter::AllowInterFrameCompression::Yes };
21+
Optional<int> frame_duration_ms;
2122
};
2223

2324
static ErrorOr<Options> parse_options(Main::Arguments arguments)
@@ -36,6 +37,8 @@ static ErrorOr<Options> parse_options(Main::Arguments arguments)
3637
bool inter_frame_compression_none = false;
3738
args_parser.add_option(inter_frame_compression_none, "Do not store incremental frames. Produces larger files.", "inter-frame-compression=none");
3839

40+
args_parser.add_option(options.frame_duration_ms, "Frame duration in ms (default: from input)", "frame-duration-ms", {}, {});
41+
3942
args_parser.parse(arguments);
4043

4144
if (options.out_path.is_empty())
@@ -96,9 +99,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
9699
for (auto const& decoder : decoders) {
97100
for (size_t i = 0; i < decoder->frame_count(); ++i) {
98101
auto frame = TRY(decoder->frame(i));
99-
100-
// FIXME: Make overridable, at least for single-frame inputs?
101-
auto frame_duration = frame.duration;
102+
auto frame_duration = options.frame_duration_ms.value_or(frame.duration);
102103

103104
if (options.write_full_frames) {
104105
TRY(animation_writer->add_frame(*frame.image, frame_duration));

0 commit comments

Comments
 (0)