From 15f5c9a1433bccf8a85a12713079c0aad0650dfa Mon Sep 17 00:00:00 2001 From: dec05eba Date: Mon, 4 Dec 2023 16:20:14 +0100 Subject: Support bmp and avif --- src/AsyncImageLoader.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/AsyncImageLoader.cpp') diff --git a/src/AsyncImageLoader.cpp b/src/AsyncImageLoader.cpp index 0ddc10c..8b8c5f6 100644 --- a/src/AsyncImageLoader.cpp +++ b/src/AsyncImageLoader.cpp @@ -26,7 +26,7 @@ #pragma GCC diagnostic pop namespace QuickMedia { - static bool webp_to_png(const Path &thumbnail_path, const Path &destination_path) { + static bool ffmpeg_image_to_png(const Path &thumbnail_path, const Path &destination_path) { const char *args[] = { "ffmpeg", "-y", "-v", "quiet", "-i", thumbnail_path.data.c_str(), "--", destination_path.data.c_str(), nullptr}; return exec_program(args, nullptr, nullptr) == 0; } @@ -34,10 +34,10 @@ namespace QuickMedia { bool create_thumbnail(const Path &thumbnail_path, const Path &thumbnail_path_resized, mgl::vec2i resize_target_size, ContentType content_type) { Path input_path = thumbnail_path; - if(content_type == ContentType::IMAGE_WEBP) { + if(content_type == ContentType::IMAGE_WEBP || content_type == ContentType::IMAGE_AVIF) { Path result_path_tmp = thumbnail_path_resized; result_path_tmp.append(".tmp.png"); - if(!webp_to_png(thumbnail_path, result_path_tmp)) + if(!ffmpeg_image_to_png(thumbnail_path, result_path_tmp)) return false; input_path = std::move(result_path_tmp); } @@ -69,7 +69,7 @@ namespace QuickMedia { result_path_tmp.append(".tmp.png"); if(image.get_size().x <= resize_target_size.x && image.get_size().y <= resize_target_size.y) { - if(content_type == ContentType::IMAGE_WEBP) { + if(content_type == ContentType::IMAGE_WEBP || content_type == ContentType::IMAGE_AVIF) { if(rename_atomic(input_path.data.c_str(), thumbnail_path_resized.data.c_str()) == 0) _exit(0); else -- cgit v1.2.3