Skip to content

Commit

Permalink
Allow use of decimal numbers as parameter for --treshold (-T) option.
Browse files Browse the repository at this point in the history
  • Loading branch information
tjko committed Jan 2, 2023
1 parent 3401f25 commit 8c68bac
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions jpegoptim.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ int save_xmp = 1;
int save_adobe = 0;
int save_jfxx = 0;
int strip_none = 0;
int threshold = -1;
double threshold = -1.0;
int csv = 0;
int all_normal = 0;
int all_progressive = 0;
Expand Down Expand Up @@ -392,8 +392,8 @@ void parse_arguments(int argc, char **argv, char *dest_path)
break;
case 'T':
{
int tmpvar;
if (sscanf(optarg,"%d",&tmpvar) == 1) {
double tmpvar;
if (sscanf(optarg,"%lf", &tmpvar) == 1) {
threshold=tmpvar;
if (threshold < 0) threshold=0;
if (threshold > 100) threshold=100;
Expand All @@ -404,7 +404,7 @@ void parse_arguments(int argc, char **argv, char *dest_path)
case 'S':
{
unsigned int tmpvar;
if (sscanf(optarg,"%u",&tmpvar) == 1) {
if (sscanf(optarg,"%u", &tmpvar) == 1) {
if (tmpvar > 0 && tmpvar < 100 &&
optarg[strlen(optarg)-1] == '%' ) {
target_size=-tmpvar;
Expand Down Expand Up @@ -1197,10 +1197,10 @@ int main(int argc, char **argv)
log_fh = (stdout_mode ? stderr : stdout);

if (verbose_mode) {
if (quality>=0 && target_size==0)
if (quality >= 0 && target_size == 0)
fprintf(log_fh, "Image quality limit set to: %d\n", quality);
if (threshold>=0)
fprintf(log_fh, "Compression threshold (%%) set to: %d\n", threshold);
if (threshold >= 0)
fprintf(log_fh, "Compression threshold (%%) set to: %0.1lf\n", threshold);
if (all_normal)
fprintf(log_fh, "All output files will be non-progressive\n");
if (all_progressive)
Expand Down

0 comments on commit 8c68bac

Please sign in to comment.