Commit bc1dbaaf authored by Mathieu Malaterre's avatar Mathieu Malaterre

Import Upstream version 1.2.4

parent e82afe27
jpegoptim
=========
Copyright (C) 1996-2002 Timo Kokkonen
Copyright (C) 1996-2011 Timo Kokkonen <tjko@iki.fi>
This program is free software; you can redistribute it
......
#########################################################################
# $Id: Makefile.in,v 1.6 2002/12/09 01:56:56 tjko Exp $
# $Id: Makefile.in,v 1.8 2011/03/31 05:37:04 tjko Exp $
#
# Makefile for jpegoptim
#
Version = 1.2.2
Version = 1.2.4
PKGNAME = jpegoptim
SHELL = /bin/sh
......@@ -32,7 +32,7 @@ mandir = $(prefix)/share/man
CC = @CC@
XCPPFLAGS = @CPPFLAGS@
CFLAGS = @CFLAGS@ $(XCPPFLAGS) $(DEFS)
CFLAGS = @CFLAGS@ $(XCPPFLAGS) $(DEFS) -Wall
LDFLAGS = @LDFLAGS@
LIBS = @LIBS@
STRIP = strip
......@@ -79,7 +79,7 @@ printable.man:
groff -Tps -mandoc ./$(PKGNAME).1 >$(PKGNAME).ps
groff -Tascii -mandoc ./$(PKGNAME).1 | tee $(PKGNAME).prn | sed 's/.//g' >$(PKGNAME).txt
install.man:
install.man: install.dirs
$(INSTALL) -m 644 $(PKGNAME).1 $(INSTALL_ROOT)/$(mandir)/man1/$(PKGNAME).1
install.dirs:
......
Jpegoptim v1.2.3 Copyright (c) Timo Kokkonen, 1996,2002,2009.
Jpegoptim v1.2.4 Copyright (c) Timo Kokkonen, 1996-2011.
REQUIREMENTS
......@@ -17,8 +17,8 @@ INSTALLATION
tar file, make nesessary changes to the Makefile, and then
compile the program. You may wanna do something like this:
zcat jpegoptim-1.2.3.tar.gz | tar xf -
cd jpegoptim-1.2.3
zcat jpegoptim-1.2.4.tar.gz | tar xf -
cd jpegoptim-1.2.4
./configure
make
make strip
......@@ -26,6 +26,9 @@ INSTALLATION
HISTORY
v1.2.4 - new -T / --treshold option by Matteo Croce,
minor fixes (potential memory leaks),
merged some patches from Debian jpegoptim package (1.2.3-2)
v1.2.3 - IPTC marker support by Dustin Ward,
ICC profile support by Dwight Kelly,
minor fixes
......@@ -51,5 +54,5 @@ LATEST VERSION
Timo <tjko@iki.fi>
30-Sep-2009
29-Mar-2011
This diff is collapsed.
......@@ -32,7 +32,9 @@ are the following:
.TP 0.6i
.B -d<path>, --dest=<path>
Sets alternative destination directory where to save optimized files
(default is to overwrite the originals).
(default is to overwrite the originals). Please note that unchanged files
won't be added to the destination directory. This means if the source
file can't be compressed, no file will be created in the destination path.
.TP 0.6i
.B -f, --force
Force optimization, even if the result would be larger than the original
......@@ -52,6 +54,9 @@ lossless optimization method.
.B -n, --noaction
Don't really optimize files, just print results.
.TP 0.6i
.B -T[0..100], --threshold=[0..100]
Keep the file unchanged if the compression gain is lower than the threshold (%).
.TP 0.6i
.B -o, --overwrite
Overwrite target file even if it exists (when using -d option).
.TP 0.6i
......
/*******************************************************************
* JPEGoptim
* Copyright (c) Timo Kokkonen, 1996,2002,2004.
* Copyright (c) Timo Kokkonen, 1996-2011.
*
* requires libjpeg.a (from JPEG Group's JPEG software
* release 6a or later...)
*
* $Id: jpegoptim.c,v 1.14 2009/09/30 07:16:58 tjko Exp $
* $Id: jpegoptim.c,v 1.19 2011/04/03 04:16:39 tjko Exp $
*/
#ifdef HAVE_CONFIG_H
......@@ -36,7 +36,7 @@
#include <libgen.h>
#endif
#define VERSIO "1.2.3"
#define VERSIO "1.2.4"
#ifdef BROKEN_METHODDEF
#undef METHODDEF
......@@ -66,7 +66,7 @@ struct jpeg_decompress_struct dinfo;
struct jpeg_compress_struct cinfo;
struct my_error_mgr jcerr,jderr;
const char *rcsid = "$Id: jpegoptim.c,v 1.14 2009/09/30 07:16:58 tjko Exp $";
const char *rcsid = "$Id: jpegoptim.c,v 1.19 2011/04/03 04:16:39 tjko Exp $";
struct option long_options[] = {
{"verbose",0,0,'v'},
......@@ -84,6 +84,7 @@ struct option long_options[] = {
{"strip-exif",0,0,'e'},
{"strip-iptc",0,0,'i'},
{"strip-icc",0,0,'P'},
{"threshold",1,0,'T'},
{0,0,0,0}
};
......@@ -102,6 +103,7 @@ int save_exif = 1;
int save_iptc = 1;
int save_com = 1;
int save_icc = 1;
int threshold = -1;
char *outfname = NULL;
FILE *infile = NULL, *outfile = NULL;
......@@ -138,7 +140,7 @@ void p_usage(void)
{
if (!quiet_mode) {
fprintf(stderr,"jpegoptim v" VERSIO
" Copyright (c) Timo Kokkonen, 1996-2009.\n");
" Copyright (c) Timo Kokkonen, 1996-2011.\n");
fprintf(stderr,
"Usage: jpegoptim [options] <filenames> \n\n"
......@@ -151,6 +153,8 @@ void p_usage(void)
" set maximum image quality factor (disables lossless\n"
" optimization mode, which is by default on)\n"
" -n, --noaction don't really optimize files, just print results\n"
" -T[0..100], --threshold\n"
" keep old file if the gain is below a threshold (%%)\n"
" -o, --overwrite overwrite target file even if it exists\n"
" -p, --preserve preserve file timestamps\n"
" -q, --quiet quiet mode\n"
......@@ -331,7 +335,7 @@ int main(int argc, char **argv)
/* parse command line parameters */
while(1) {
opt_index=0;
if ((c=getopt_long(argc,argv,"d:hm:ntqvfVpo",long_options,&opt_index))
if ((c=getopt_long(argc,argv,"d:hm:ntqvfVpoT:",long_options,&opt_index))
== -1)
break;
......@@ -345,9 +349,8 @@ int main(int argc, char **argv)
if (quality < 0) quality=0;
if (quality > 100) quality=100;
}
else if (!quiet_mode) {
else
fatal("invalid argument for -m, --max");
}
}
break;
case 'd':
......@@ -380,7 +383,7 @@ int main(int argc, char **argv)
break;
case 'V':
printf("jpegoptim v%s %s\n",VERSIO,HOST_TYPE);
printf("Copyright (c) Timo Kokkonen, 1996-2009.\n");
printf("Copyright (c) Timo Kokkonen, 1996-2011.\n");
exit(0);
break;
case 'o':
......@@ -407,6 +410,17 @@ int main(int argc, char **argv)
case 'P':
save_icc=0;
break;
case 'T':
{
int tmpvar;
if (sscanf(optarg,"%d",&tmpvar) == 1) {
threshold=tmpvar;
if (threshold < 0) threshold=0;
if (threshold > 100) threshold=100;
}
else fatal("invalid argument for -T, --threshold");
}
break;
default:
if (!quiet_mode)
......@@ -415,9 +429,11 @@ int main(int argc, char **argv)
}
if (verbose_mode && (quality>0))
if (verbose_mode && (quality>=0))
fprintf(stderr,"Image quality limit set to: %d\n",quality);
if (verbose_mode && (threshold>=0))
fprintf(stderr,"Compression treshold (%%) set to: %d\n",threshold);
/* loop to process the input files */
i=1;
......@@ -460,6 +476,10 @@ int main(int argc, char **argv)
if (setjmp(jderr.setjmp_buffer)) {
jpeg_abort_decompress(&dinfo);
fclose(infile);
if (buf) {
for (j=0;j<dinfo.output_height;j++) free(buf[j]);
free(buf); buf=NULL;
}
printf(" [ERROR]\n");
continue;
}
......@@ -544,8 +564,10 @@ int main(int argc, char **argv)
fprintf(stderr,"target file already exists!\n");
jpeg_abort_decompress(&dinfo);
fclose(infile);
for (j=0;j<dinfo.output_height;j++) free(buf[j]);
free(buf); buf=NULL;
if (buf) {
for (j=0;j<dinfo.output_height;j++) free(buf[j]);
free(buf); buf=NULL;
}
continue;
}
}
......@@ -565,8 +587,10 @@ int main(int argc, char **argv)
fclose(outfile);
if (infile) fclose(infile);
printf(" [Compress ERROR]\n");
for (j=0;j<dinfo.output_height;j++) free(buf[j]);
free(buf); buf=NULL;
if (buf) {
for (j=0;j<dinfo.output_height;j++) free(buf[j]);
free(buf); buf=NULL;
}
if (file_exists(outfname)) delete_file(outfname);
outfname=NULL;
continue;
......@@ -637,7 +661,7 @@ int main(int argc, char **argv)
average_count++;
average_rate+=(ratio<0 ? 0.0 : ratio);
if (outsize<insize || force) {
if ((outsize < insize && ratio >= threshold) || force) {
total_save+=(insize-outsize)/1024.0;
printf("optimized.\n");
if (noaction) continue;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment