summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorNico Weber <thakis@chromium.org>2023-02-26 13:57:48 -0500
committerAndreas Kling <kling@serenityos.org>2023-02-27 13:29:57 +0100
commit5d5f9f52a0cd586fe9ff7ec96c3b5a04d155ae4d (patch)
tree3ef81bd2d788b12e2a997098a055ab8008837b80 /Userland
parenta83f4ec1869549018f7f1b77f395db111050fbb5 (diff)
downloadserenity-5d5f9f52a0cd586fe9ff7ec96c3b5a04d155ae4d.zip
Utilities: Make `file` print more information for animated images
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Utilities/file.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/Userland/Utilities/file.cpp b/Userland/Utilities/file.cpp
index 7e189dcbf6..3901b004a7 100644
--- a/Userland/Utilities/file.cpp
+++ b/Userland/Utilities/file.cpp
@@ -37,7 +37,18 @@ static Optional<DeprecatedString> image_details(DeprecatedString const& descript
if (!image_decoder)
return {};
- return DeprecatedString::formatted("{}, {} x {}", description, image_decoder->width(), image_decoder->height());
+ StringBuilder builder;
+ builder.appendff("{}, {} x {}", description, image_decoder->width(), image_decoder->height());
+ if (image_decoder->is_animated()) {
+ builder.appendff(", animated with {} frames that loop", image_decoder->frame_count());
+ int loop_count = image_decoder->loop_count();
+ if (loop_count == 0)
+ builder.appendff(" indefinitely");
+ else
+ builder.appendff(" {} {}", loop_count, loop_count == 1 ? "time" : "times");
+ }
+
+ return builder.to_deprecated_string();
}
static Optional<DeprecatedString> gzip_details(DeprecatedString description, DeprecatedString const& path)