From 0d611aa212fd6429b41819e59933866142718427 Mon Sep 17 00:00:00 2001 From: Stefan Pöschel Date: Mon, 18 Mar 2024 18:13:43 +0100 Subject: SLS: improve resolution warning Mention whether the image was resized or not. Fixes #16. --- src/sls.cpp | 12 +++++++----- src/sls.h | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/sls.cpp b/src/sls.cpp index f6cfb6f..4477af7 100644 --- a/src/sls.cpp +++ b/src/sls.cpp @@ -261,9 +261,11 @@ const int SLSEncoder::APPTYPE_MOT_CONT = 13; const std::string SLSEncoder::REQUEST_REREAD_FILENAME = "REQUEST_SLIDES_DIR_REREAD"; -void SLSEncoder::warnOnSmallerImage(size_t height, size_t width, const std::string& fname) { - if (height < 240 || width < 320) - fprintf(stderr, "ODR-PadEnc Warning: Image '%s' smaller than recommended size (%zu x %zu < 320 x 240 px)\n", fname.c_str(), width, height); +void SLSEncoder::warnOnSmallerImage(size_t height, size_t width, const std::string& fname, bool resized) { + if (height < 240 || width < 320) { + fprintf(stderr, "ODR-PadEnc Warning: %s '%s' smaller than recommended size (%zu x %zu < 320 x 240 px)\n", + resized ? "Resized image" : "Image", fname.c_str(), width, height); + } } @@ -345,7 +347,7 @@ size_t SLSEncoder::resizeImage(MagickWand* m_wand, unsigned char** blob, const s } // warn if resized image smaller than default dimension - warnOnSmallerImage(height, width, fname); + warnOnSmallerImage(height, width, fname, true); MagickRelinquishMemory(*jfif_not_png ? blob_png : blob_jpg); *blob = *jfif_not_png ? blob_jpg : blob_png; @@ -485,7 +487,7 @@ bool SLSEncoder::encodeSlide(const std::string& fname, int fidx, bool raw_slides blobsize = resizeImage(m_wand, &magick_blob, fname, &jfif_not_png, max_slide_size); } else { // warn if unresized image smaller than default dimension - warnOnSmallerImage(height, width, fname); + warnOnSmallerImage(height, width, fname, false); } #else diff --git a/src/sls.h b/src/sls.h index dbbcf3c..4e25fee 100644 --- a/src/sls.h +++ b/src/sls.h @@ -227,7 +227,7 @@ private: static const int MINQUALITY; static const std::string SLS_PARAMS_SUFFIX; - void warnOnSmallerImage(size_t height, size_t width, const std::string& fname); + void warnOnSmallerImage(size_t height, size_t width, const std::string& fname, bool resized); #if HAVE_MAGICKWAND size_t resizeImage(MagickWand* m_wand, unsigned char** blob, const std::string& fname, bool* jfif_not_png, size_t max_slide_size); #endif -- cgit v1.2.3