aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2020-10-05 14:06:00 +0200
committerdec05eba <dec05eba@protonmail.com>2020-10-05 14:06:00 +0200
commit19ffb223cbc3eb62ae96d837aa07a4eea03c2b7e (patch)
tree30ba29ecd19b7037482f5d43a651b25075aef9b6 /src
parent27d5c7dcc37b0064801741a7c1e5500160c4c2d7 (diff)
Manga: add --upscale-images-force to force upscaling, regardless of original image resolution
Diffstat (limited to 'src')
-rw-r--r--src/QuickMedia.cpp23
1 files changed, 17 insertions, 6 deletions
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index dfd4551..8865adb 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -252,7 +252,7 @@ namespace QuickMedia {
}
Program::~Program() {
- if(upscale_images && running) {
+ if(upscale_image_action != UpscaleImageAction::NO && running) {
running = false;
{
std::unique_lock<std::mutex> lock(image_upscale_mutex);
@@ -299,6 +299,7 @@ namespace QuickMedia {
fprintf(stderr, " --tor Use tor. Disabled by default\n");
fprintf(stderr, " --use-system-mpv-config Use system mpv config instead of no config. Disabled by default\n");
fprintf(stderr, " --upscale-images Upscale low-resolution manga pages using waifu2x-ncnn-vulkan. Disabled by default\n");
+ fprintf(stderr, " --upscale-images-force Upscale manga pages using waifu2x-ncnn-vulkan, no matter what the original image resolution is. Disabled by default\n");
fprintf(stderr, " --dir Set the start directory when using file-manager\n");
fprintf(stderr, " -p Change the placeholder text for dmenu\n");
fprintf(stderr, "EXAMPLES:\n");
@@ -381,7 +382,9 @@ namespace QuickMedia {
} else if(strcmp(argv[i], "--use-system-mpv-config") == 0) {
use_system_mpv_config = true;
} else if(strcmp(argv[i], "--upscale-images") == 0) {
- upscale_images = true;
+ upscale_image_action = UpscaleImageAction::LOW_RESOLUTION;
+ } else if(strcmp(argv[i], "--upscale-images-force") == 0) {
+ upscale_image_action = UpscaleImageAction::FORCE;
} else if(strcmp(argv[i], "--dir") == 0) {
if(i < argc - 1) {
start_dir = argv[i + 1];
@@ -434,14 +437,14 @@ namespace QuickMedia {
return -2;
}
- if(upscale_images) {
+ if(upscale_image_action != UpscaleImageAction::NO) {
if(!current_plugin->is_manga()) {
- fprintf(stderr, "Option --upscale-images is only valid for manganelo, mangatown and mangadex\n");
+ fprintf(stderr, "Option --upscale-images/-upscale-images-force is only valid for manganelo, mangatown and mangadex\n");
return -2;
}
if(!is_program_executable_by_name("waifu2x-ncnn-vulkan")) {
- fprintf(stderr, "waifu2x-ncnn-vulkan needs to be installed (and accessible from PATH environment variable) when using the --upscale-images option\n");
+ fprintf(stderr, "waifu2x-ncnn-vulkan needs to be installed (and accessible from PATH environment variable) when using the --upscale-images/--upscale-images-force option\n");
return -2;
}
@@ -2040,7 +2043,7 @@ namespace QuickMedia {
}
bool rename_immediately = true;
- if(upscale_images) {
+ if(upscale_image_action == UpscaleImageAction::LOW_RESOLUTION) {
int screen_width, screen_height;
get_screen_resolution(disp, &screen_width, &screen_height);
@@ -2060,6 +2063,14 @@ namespace QuickMedia {
} else {
fprintf(stderr, "Warning: failed to upscale %s because QuickMedia failed to recognize the resolution of the image\n", image_filepath_tmp.data.c_str());
}
+ } else if(upscale_image_action == UpscaleImageAction::FORCE) {
+ rename_immediately = false;
+ CopyOp copy_op;
+ copy_op.source = image_filepath_tmp;
+ copy_op.destination = image_filepath;
+ std::unique_lock<std::mutex> lock(image_upscale_mutex);
+ images_to_upscale.push_back(std::move(copy_op));
+ image_upscale_cv.notify_one();
}
if(rename_immediately) {