From b7c30f30962d5f13136f09b9a1fe006699784556 Mon Sep 17 00:00:00 2001 From: Lucas CHOLLET Date: Tue, 20 Jun 2023 16:33:51 -0400 Subject: [PATCH] image: Support JPEG as an output format --- Userland/Utilities/image.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Userland/Utilities/image.cpp b/Userland/Utilities/image.cpp index c47fb42230..2fccbb1c8d 100644 --- a/Userland/Utilities/image.cpp +++ b/Userland/Utilities/image.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -152,6 +153,9 @@ ErrorOr serenity_main(Main::Arguments arguments) auto const format = ppm_ascii ? Gfx::PortableFormatWriter::Options::Format::ASCII : Gfx::PortableFormatWriter::Options::Format::Raw; TRY(Gfx::PortableFormatWriter::encode(*buffered_stream, *frame, { .format = format })); return 0; + } else if (out_path.ends_with(".jpg"sv, CaseSensitivity::CaseInsensitive) || out_path.ends_with(".jpeg"sv, CaseSensitivity::CaseInsensitive)) { + TRY(Gfx::JPEGWriter::encode(*buffered_stream, *frame)); + return 0; } else if (out_path.ends_with(".qoi"sv, CaseSensitivity::CaseInsensitive)) { bytes = TRY(Gfx::QOIWriter::encode(*frame)); } else {