diff options
-rw-r--r-- | src/AsyncImageLoader.cpp | 8 | ||||
-rw-r--r-- | src/plugins/FileManager.cpp | 6 |
2 files changed, 9 insertions, 5 deletions
diff --git a/src/AsyncImageLoader.cpp b/src/AsyncImageLoader.cpp index 6504992..947f637 100644 --- a/src/AsyncImageLoader.cpp +++ b/src/AsyncImageLoader.cpp @@ -15,8 +15,9 @@ namespace QuickMedia { // TODO: Remove this when imagemagick supports webp // Convert webp to png + bool remove_tmp_input = false; if(content_type == ContentType::IMAGE_WEBP) { - Path result_path_tmp = input_path; + Path result_path_tmp = thumbnail_path_resized; result_path_tmp.append(".tmp.png"); const char *args[] = { "ffmpeg", "-y", "-v", "quiet", "-i", input_path.data.c_str(), "--", result_path_tmp.data.c_str(), nullptr}; @@ -25,13 +26,14 @@ namespace QuickMedia { return false; input_path = std::move(result_path_tmp); + remove_tmp_input = true; } // > is to only shrink image if smaller than the target size std::string new_size = std::to_string(resize_target_size.x) + "x" + std::to_string(resize_target_size.y) + ">"; // We only want the first frame if its a gif - Path thumbnail_path_first_frame = std::move(input_path); + Path thumbnail_path_first_frame = input_path; thumbnail_path_first_frame.append("[0]"); Path result_path_tmp = thumbnail_path_resized; @@ -39,6 +41,8 @@ namespace QuickMedia { const char *args[] = { "convert", thumbnail_path_first_frame.data.c_str(), "-thumbnail", new_size.c_str(), result_path_tmp.data.c_str(), nullptr}; int convert_res = exec_program(args, nullptr, nullptr); + if(remove_tmp_input) + remove(input_path.data.c_str()); if(convert_res == 0 && rename_atomic(result_path_tmp.data.c_str(), thumbnail_path_resized.data.c_str()) == 0) return true; else diff --git a/src/plugins/FileManager.cpp b/src/plugins/FileManager.cpp index 814ee70..47a8b57 100644 --- a/src/plugins/FileManager.cpp +++ b/src/plugins/FileManager.cpp @@ -30,11 +30,11 @@ namespace QuickMedia { char result[32]; if(gb >= 1.0) - snprintf(result, sizeof(result), "%.2f GiB", gb); + snprintf(result, sizeof(result), "%.1f GiB", gb); else if(mb >= 1.0) - snprintf(result, sizeof(result), "%.2f MiB", mb); + snprintf(result, sizeof(result), "%.1f MiB", mb); else if(kb >= 1.0) - snprintf(result, sizeof(result), "%.2f KiB", kb); + snprintf(result, sizeof(result), "%.1f KiB", kb); else snprintf(result, sizeof(result), "%zu bytes", bytes); |