# https://github.com/Diaron/CutyCapt # commit bea8c782dba815ff7f2d688d113b05e3c2fe82f7 ... 2602b6243c67713298d411abec8867c5471f0094 # Author: Diaron # Date: Tue May 20 16:03:06 2014 +0300 Added --image-save-quality command line parameter for setting image quality while saving screenshot to image --- CutyCapt.cpp.orig 2021-06-20 07:52:48.927798808 +0000 +++ CutyCapt.cpp 2021-06-20 08:02:50.774304464 +0000 @@ -168,7 +168,7 @@ } // TODO: Consider merging some of main() and CutyCap -CutyCapt::CutyCapt(CutyPage* page, const QString& output, int delay, OutputFormat format, +CutyCapt::CutyCapt(CutyPage* page, const QString& output, int delay, OutputFormat format, int OutQuality, const QString& scriptProp, const QString& scriptCode, const QString& cookieJarPath,bool insecure, bool smooth, QPrinter::Orientation orientation, QPrinter::PaperSize paperSize) { mPage = page; @@ -179,6 +179,7 @@ mSawInitialLayout = false; mSawDocumentComplete = false; mFormat = format; + mOutQuality = OutQuality; mScriptProp = scriptProp; mScriptCode = scriptCode; mCookieJarPath = cookieJarPath; @@ -357,8 +358,7 @@ #endif mainFrame->render(&painter); painter.end(); - // TODO: add quality - image.save(mOutput, format); + image.save(mOutput, format, mOutQuality); } }; } @@ -373,7 +373,7 @@ " --url= The URL to capture (http:...|file:...|...) \n" " --out= The target file (.png|pdf|ps|svg|jpeg|...) \n" " --out-format= Like extension in --out, overrides heuristic \n" -// " --out-quality= Output format quality from 1 to 100 \n" + " --image-save-quality= Output format quality, 1..100 (default: 75) \n" " --min-width= Minimal width for the image (default: 800) \n" " --min-height= Minimal height for the image (default: 600) \n" " --max-wait= Don't wait more than (default: 90000, inf: 0)\n" @@ -441,6 +441,7 @@ int argDelay = 0; int argSilent = 0; int argInsecure = 0; + int argOutQuality = 75; int argMinWidth = 800; int argMinHeight = 600; int argMaxWait = 90000; @@ -523,6 +524,13 @@ if (strncmp("--url", s, nlen) == 0) { argUrl = QByteArray(value); + } else if (strncmp("--image-save-quality", s, nlen) == 0) { + int nArgValue = atoi(value); + if( 1 <= nArgValue && 100 >= nArgValue ) + argOutQuality = nArgValue; + else + argOutQuality = 75; + } else if (strncmp("--min-width", s, nlen) == 0) { // TODO: add error checking here? argMinWidth = (unsigned int)atoi(value); @@ -737,7 +745,7 @@ } } - CutyCapt main(&page, argOut, argDelay, format, scriptProp, scriptCode, cookieJarPath,!!argInsecure, !!argSmooth,orientation,paperSize); + CutyCapt main(&page, argOut, argDelay, format, argOutQuality, scriptProp, scriptCode, cookieJarPath,!!argInsecure, !!argSmooth,orientation,paperSize); app.connect(&page, --- CutyCapt.hpp.orig 2021-06-20 07:52:31.256678043 +0000 +++ CutyCapt.hpp 2021-06-20 08:02:50.812304713 +0000 @@ -46,6 +46,7 @@ const QString& output, int delay, OutputFormat format, + int argOutQuality, const QString& scriptProp, const QString& scriptCode, const QString& cookieJarPath, @@ -75,6 +76,7 @@ int mDelay; CutyPage* mPage; OutputFormat mFormat; + int mOutQuality; QObject* mScriptObj; QString mScriptProp; QString mScriptCode;