Dropped scaling support
This commit is contained in:
parent
ef39a3b5f1
commit
a0fe4ace10
|
@ -19,7 +19,6 @@ cclt_compress_parameters initialize_compression_parameters() {
|
|||
par.quality = 0;
|
||||
par.width = 0;
|
||||
par.height = 0;
|
||||
par.scaling_factor = 100;
|
||||
par.color_space = TJCS_RGB;
|
||||
par.dct_method = TJFLAG_FASTDCT;
|
||||
par.output_folder = NULL;
|
||||
|
@ -75,9 +74,6 @@ cclt_compress_parameters parse_arguments(int argc, char* argv[]) {
|
|||
case 'o':
|
||||
parameters.output_folder = optarg;
|
||||
break;
|
||||
case 's':
|
||||
parameters.scaling_factor = string_to_int(optarg);
|
||||
break;
|
||||
case 'h':
|
||||
print_help();
|
||||
break;
|
||||
|
@ -119,6 +115,10 @@ int cclt_compress_routine(char* input, char* output, cclt_compress_parameters* p
|
|||
} else if (type == JPEG && pars->lossless != 0) {
|
||||
cclt_jpeg_optimize(input, output, pars->exif_copy, input);
|
||||
} else if (type == PNG) {
|
||||
//Give a message to the user if he set a quality for PNGs
|
||||
if (pars->quality != 0) {
|
||||
printf("PNG file, ignoring quality parameter.\n");
|
||||
}
|
||||
cclt_png_optimize(input, output);
|
||||
} else {
|
||||
printf("Unknown file type.\n");
|
||||
|
|
|
@ -211,8 +211,8 @@ unsigned char* cclt_jpeg_decompress(char* fileName, cclt_compress_parameters* pa
|
|||
tjDecompressHandle = tjInitDecompress();
|
||||
res = tjDecompressHeader3(tjDecompressHandle, sourceJpegBuffer, sourceJpegBufferSize, &fileWidth, &fileHeight, &jpegSubsamp, &colorSpace);
|
||||
|
||||
pars->width = ceil(fileWidth * ((double) pars->scaling_factor / 100));
|
||||
pars->height = ceil(fileHeight * ((double) pars->scaling_factor / 100));
|
||||
pars->width = fileWidth;
|
||||
pars->height = fileHeight;
|
||||
|
||||
pars->subsample = jpegSubsamp;
|
||||
pars->color_space = colorSpace;
|
||||
|
|
21
src/main.c
21
src/main.c
|
@ -1,6 +1,5 @@
|
|||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <getopt.h>
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
|
@ -8,6 +7,7 @@
|
|||
#include <libgen.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "jpeg.h"
|
||||
#include "compresshelper.h"
|
||||
|
@ -19,7 +19,6 @@
|
|||
-o output folder v
|
||||
-v version v
|
||||
-l lossless v
|
||||
-s scale v
|
||||
-h help v
|
||||
-R recursive v
|
||||
-S keep folder structure
|
||||
|
@ -146,12 +145,6 @@ int main (int argc, char *argv[]) {
|
|||
exit(-9);
|
||||
}
|
||||
|
||||
//Check if there's a valid scaling factor
|
||||
if (pars.scaling_factor <= 0) {
|
||||
fprintf(stderr, "Scaling factor must be > 0. Aborting.\n");
|
||||
exit(-6);
|
||||
}
|
||||
|
||||
//Check if the output folder exists, otherwise create it
|
||||
if (pars.output_folder == NULL) {
|
||||
fprintf(stderr, "No -o option pointing to the destination folder. Aborting.\n");
|
||||
|
@ -164,15 +157,15 @@ int main (int argc, char *argv[]) {
|
|||
}
|
||||
}
|
||||
|
||||
if ((pars.lossless == 1) && (pars.scaling_factor != 100)) {
|
||||
fprintf(stderr, "Lossless scaling is not supported. Use -q instead. Aborting.\n");
|
||||
exit(-13);
|
||||
}
|
||||
|
||||
//Start a timer
|
||||
clock_t start = clock(), diff;
|
||||
//We need the file list right here
|
||||
cclt_start(pars.input_files, pars.input_files_count, pars.output_folder, &pars, &i_t_size, &o_t_size);
|
||||
diff = clock() - start;
|
||||
|
||||
fprintf(stdout, "-------------------------------\nCompression completed.\n%s -> %s [%.2f%% | %s]\n",
|
||||
fprintf(stdout, "-------------------------------\nCompression completed in %lum%lus\n%s -> %s [%.2f%% | %s]\n",
|
||||
diff / CLOCKS_PER_SEC / 60,
|
||||
diff / CLOCKS_PER_SEC % 60,
|
||||
get_human_size((long) i_t_size),
|
||||
get_human_size((long) o_t_size),
|
||||
((float) o_t_size - i_t_size) * 100 / i_t_size,
|
||||
|
|
|
@ -18,11 +18,11 @@ void cclt_png_optimize(char* input, char* output) {
|
|||
unsigned char* resultpng;
|
||||
size_t resultpng_size;
|
||||
|
||||
png_options.num_iterations = 10;
|
||||
png_options.num_iterations_large = 15;
|
||||
png_options.block_split_strategy = 3;
|
||||
png_options.num_iterations = 15;
|
||||
png_options.num_iterations_large = 5;
|
||||
png_options.block_split_strategy = 4;
|
||||
|
||||
png_options.lossy_8bit = 1;
|
||||
png_options.lossy_8bit = 0;
|
||||
png_options.lossy_transparent = 1;
|
||||
|
||||
png_options.auto_filter_strategy = 1;
|
||||
|
|
|
@ -182,6 +182,7 @@ enum image_type detect_image_type(char* path) {
|
|||
free(type_buffer);
|
||||
return PNG;
|
||||
} else {
|
||||
free(type_buffer);
|
||||
return UNKN;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,6 @@ typedef struct cclt_compress_parameters {
|
|||
int quality;
|
||||
int width;
|
||||
int height;
|
||||
int scaling_factor;
|
||||
char* output_folder;
|
||||
int color_space;
|
||||
int dct_method;
|
||||
|
|
Loading…
Reference in New Issue