Commit 861370a4 authored by Mathieu Malaterre's avatar Mathieu Malaterre

Import Upstream version 1.2.5

parent bc1dbaaf
*.c ident
*.in ident
README ident
######################################################################### #########################################################################
# $Id: Makefile.in,v 1.8 2011/03/31 05:37:04 tjko Exp $ # $Id$
# #
# Makefile for jpegoptim # Makefile for jpegoptim
# #
Version = 1.2.4 Version = 1.2.5
PKGNAME = jpegoptim PKGNAME = jpegoptim
SHELL = /bin/sh SHELL = /bin/sh
...@@ -71,6 +71,10 @@ dist: clean_all ...@@ -71,6 +71,10 @@ dist: clean_all
backup: dist backup: dist
archive:
git archive --format tar --prefix ${DISTNAME}/ -o ../${DISTNAME}.tar master
gzip -v -9 ../${DISTNAME}.tar
install: all install.dirs install.man install: all install.dirs install.man
$(INSTALL) -m 755 $(PKGNAME) $(INSTALL_ROOT)/$(bindir)/$(PKGNAME) $(INSTALL) -m 755 $(PKGNAME) $(INSTALL_ROOT)/$(bindir)/$(PKGNAME)
......
Jpegoptim v1.2.4 Copyright (c) Timo Kokkonen, 1996-2011. Jpegoptim v1.2.5 Copyright (c) Timo Kokkonen, 1996-2013.
REQUIREMENTS REQUIREMENTS
...@@ -17,8 +17,8 @@ INSTALLATION ...@@ -17,8 +17,8 @@ INSTALLATION
tar file, make nesessary changes to the Makefile, and then tar file, make nesessary changes to the Makefile, and then
compile the program. You may wanna do something like this: compile the program. You may wanna do something like this:
zcat jpegoptim-1.2.4.tar.gz | tar xf - zcat jpegoptim-1.2.5.tar.gz | tar xf -
cd jpegoptim-1.2.4 cd jpegoptim-1.2.5
./configure ./configure
make make
make strip make strip
...@@ -26,6 +26,8 @@ INSTALLATION ...@@ -26,6 +26,8 @@ INSTALLATION
HISTORY HISTORY
v1.2.5 - safer temp file handling (if mkstemps() available),
patch to make "quiet mode" (-q) be quiet by Mathieu Malaterre
v1.2.4 - new -T / --treshold option by Matteo Croce, v1.2.4 - new -T / --treshold option by Matteo Croce,
minor fixes (potential memory leaks), minor fixes (potential memory leaks),
merged some patches from Debian jpegoptim package (1.2.3-2) merged some patches from Debian jpegoptim package (1.2.3-2)
...@@ -51,8 +53,10 @@ LATEST VERSION ...@@ -51,8 +53,10 @@ LATEST VERSION
Latest version is always available from: Latest version is always available from:
http://www.iki.fi/tjko/projects.html http://www.iki.fi/tjko/projects.html
Sources (GIT)
https://github.com/tjko/jpegoptim
Timo <tjko@iki.fi> Timo <tjko@iki.fi>
29-Mar-2011 30-Jan-2013 $Id$
/* config.h.in. /* config.h.in.
* $Id: config.h.in,v 1.2 2002/12/04 13:17:58 tjko Exp $ * $Id$
* *
*/ */
...@@ -16,6 +16,9 @@ ...@@ -16,6 +16,9 @@
/* Define if you have the getopt_long function. */ /* Define if you have the getopt_long function. */
#undef HAVE_GETOPT_LONG #undef HAVE_GETOPT_LONG
/* Define if you have mkstemps function. */
#undef HAVE_MKSTEMPS
/* Define if you have the <getopt.h> header file. */ /* Define if you have the <getopt.h> header file. */
#undef HAVE_GETOPT_H #undef HAVE_GETOPT_H
......
This diff is collapsed.
dnl $Id: configure.in,v 1.1 2002/12/04 00:25:44 tjko Exp $ dnl $Id$
dnl dnl
dnl Process this file with autoconf to produce a configure script. dnl Process this file with autoconf to produce a configure script.
AC_INIT(jpegoptim.c) AC_INIT(jpegoptim.c)
...@@ -58,6 +58,7 @@ dnl Checks for library functions. ...@@ -58,6 +58,7 @@ dnl Checks for library functions.
AC_CHECK_FUNCS(getopt_long, break, [GNUGETOPT="getopt.o getopt1.o"]) AC_CHECK_FUNCS(getopt_long, break, [GNUGETOPT="getopt.o getopt1.o"])
AC_SUBST(GNUGETOPT) AC_SUBST(GNUGETOPT)
AC_CHECK_FUNCS(mkstemps)
dnl own tests dnl own tests
......
/******************************************************************* /*******************************************************************
* JPEGoptim * JPEGoptim
* Copyright (c) Timo Kokkonen, 1996-2011. * Copyright (c) Timo Kokkonen, 1996-2013.
* All Rights Reserved.
* *
* requires libjpeg.a (from JPEG Group's JPEG software * requires libjpeg.a (from JPEG Group's JPEG software
* release 6a or later...) * release 6a or later...)
* *
* $Id: jpegoptim.c,v 1.19 2011/04/03 04:16:39 tjko Exp $ * $Id$
*/ */
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
...@@ -36,7 +37,7 @@ ...@@ -36,7 +37,7 @@
#include <libgen.h> #include <libgen.h>
#endif #endif
#define VERSIO "1.2.4" #define VERSIO "1.2.5"
#ifdef BROKEN_METHODDEF #ifdef BROKEN_METHODDEF
#undef METHODDEF #undef METHODDEF
...@@ -66,7 +67,7 @@ struct jpeg_decompress_struct dinfo; ...@@ -66,7 +67,7 @@ struct jpeg_decompress_struct dinfo;
struct jpeg_compress_struct cinfo; struct jpeg_compress_struct cinfo;
struct my_error_mgr jcerr,jderr; struct my_error_mgr jcerr,jderr;
const char *rcsid = "$Id: jpegoptim.c,v 1.19 2011/04/03 04:16:39 tjko Exp $"; const char *rcsid = "$Id$";
struct option long_options[] = { struct option long_options[] = {
{"verbose",0,0,'v'}, {"verbose",0,0,'v'},
...@@ -140,7 +141,7 @@ void p_usage(void) ...@@ -140,7 +141,7 @@ void p_usage(void)
{ {
if (!quiet_mode) { if (!quiet_mode) {
fprintf(stderr,"jpegoptim v" VERSIO fprintf(stderr,"jpegoptim v" VERSIO
" Copyright (c) Timo Kokkonen, 1996-2011.\n"); " Copyright (c) Timo Kokkonen, 1996-2013.\n");
fprintf(stderr, fprintf(stderr,
"Usage: jpegoptim [options] <filenames> \n\n" "Usage: jpegoptim [options] <filenames> \n\n"
...@@ -300,7 +301,7 @@ int main(int argc, char **argv) ...@@ -300,7 +301,7 @@ int main(int argc, char **argv)
char tmpfilename[MAXPATHLEN],tmpdir[MAXPATHLEN]; char tmpfilename[MAXPATHLEN],tmpdir[MAXPATHLEN];
char newname[MAXPATHLEN], dest_path[MAXPATHLEN]; char newname[MAXPATHLEN], dest_path[MAXPATHLEN];
volatile int i; volatile int i;
int c,j, err_count; int c,j, err_count, tmpfd;
int opt_index = 0; int opt_index = 0;
long insize,outsize; long insize,outsize;
double ratio; double ratio;
...@@ -383,7 +384,7 @@ int main(int argc, char **argv) ...@@ -383,7 +384,7 @@ int main(int argc, char **argv)
break; break;
case 'V': case 'V':
printf("jpegoptim v%s %s\n",VERSIO,HOST_TYPE); printf("jpegoptim v%s %s\n",VERSIO,HOST_TYPE);
printf("Copyright (c) Timo Kokkonen, 1996-2011.\n"); printf("Copyright (c) Timo Kokkonen, 1996-2013.\n");
exit(0); exit(0);
break; break;
case 'o': case 'o':
...@@ -457,8 +458,6 @@ int main(int argc, char **argv) ...@@ -457,8 +458,6 @@ int main(int argc, char **argv)
fatal("splitdir() failed!"); fatal("splitdir() failed!");
strncpy(newname,argv[i],sizeof(newname)); strncpy(newname,argv[i],sizeof(newname));
} }
snprintf(tmpfilename,sizeof(tmpfilename),
"%sjpegoptim-%d-%d.tmp", tmpdir, (int)getuid(), (int)getpid());
} }
retry_point: retry_point:
...@@ -484,7 +483,9 @@ int main(int argc, char **argv) ...@@ -484,7 +483,9 @@ int main(int argc, char **argv)
continue; continue;
} }
if (!retry) { printf("%s ",argv[i]); fflush(stdout); } if (!retry && !quiet_mode) {
printf("%s ",argv[i]); fflush(stdout);
}
/* prepare to decompress */ /* prepare to decompress */
global_error_counter=0; global_error_counter=0;
...@@ -518,7 +519,7 @@ int main(int argc, char **argv) ...@@ -518,7 +519,7 @@ int main(int argc, char **argv)
} }
if (!retry) { if (!retry && !quiet_mode) {
printf("%dx%d %dbit ",(int)dinfo.image_width, printf("%dx%d %dbit ",(int)dinfo.image_width,
(int)dinfo.image_height,(int)dinfo.num_components*8); (int)dinfo.image_height,(int)dinfo.num_components*8);
...@@ -552,7 +553,7 @@ int main(int argc, char **argv) ...@@ -552,7 +553,7 @@ int main(int argc, char **argv)
coef_arrays = jpeg_read_coefficients(&dinfo); coef_arrays = jpeg_read_coefficients(&dinfo);
} }
if (!retry) { if (!retry && !quiet_mode) {
if (!global_error_counter) printf(" [OK] "); if (!global_error_counter) printf(" [OK] ");
else printf(" [WARNING] "); else printf(" [WARNING] ");
fflush(stdout); fflush(stdout);
...@@ -574,17 +575,27 @@ int main(int argc, char **argv) ...@@ -574,17 +575,27 @@ int main(int argc, char **argv)
if (noaction) { if (noaction) {
outfname=NULL; outfname=NULL;
if ((outfile=tmpfile())==NULL) fatal("error opening temp file"); if ((outfile=tmpfile())==NULL) fatal("error creating temp file: tmpfile() failed");
} else { } else {
snprintf(tmpfilename,sizeof(tmpfilename),
"%sjpegoptim-%d-%d.XXXXXX.tmp", tmpdir, (int)getuid(), (int)getpid());
#ifdef HAVE_MKSTEMPS
if ((tmpfd = mkstemps(tmpfilename,4)) < 0)
fatal("error creating temp file: mkstemps() failed");
if ((outfile=fdopen(tmpfd,"w"))==NULL)
#else
tmpfd=0;
if ((outfile=fopen(tmpfilename,"w"))==NULL)
#endif
fatal("error opening temporary file");
outfname=tmpfilename; outfname=tmpfilename;
if ((outfile=fopen(outfname,"w"))==NULL)
fatal("error opening target file");
} }
if (setjmp(jcerr.setjmp_buffer)) { if (setjmp(jcerr.setjmp_buffer)) {
jpeg_abort_compress(&cinfo); jpeg_abort_compress(&cinfo);
jpeg_abort_decompress(&dinfo); jpeg_abort_decompress(&dinfo);
fclose(outfile); fclose(outfile);
outfile=NULL;
if (infile) fclose(infile); if (infile) fclose(infile);
printf(" [Compress ERROR]\n"); printf(" [Compress ERROR]\n");
if (buf) { if (buf) {
...@@ -642,6 +653,7 @@ int main(int argc, char **argv) ...@@ -642,6 +653,7 @@ int main(int argc, char **argv)
fclose(infile); fclose(infile);
outsize=file_size(outfile); outsize=file_size(outfile);
fclose(outfile); fclose(outfile);
outfile=NULL;
if (preserve_mode && !noaction) { if (preserve_mode && !noaction) {
if (utime(outfname,&time_save) != 0) { if (utime(outfname,&time_save) != 0) {
...@@ -650,6 +662,7 @@ int main(int argc, char **argv) ...@@ -650,6 +662,7 @@ int main(int argc, char **argv)
} }
if (quality>=0 && outsize>=insize && !retry) { if (quality>=0 && outsize>=insize && !retry) {
if (!noaction) delete_file(outfname);
if (verbose_mode) printf("(retry w/lossless) "); if (verbose_mode) printf("(retry w/lossless) ");
retry=1; retry=1;
goto retry_point; goto retry_point;
...@@ -657,27 +670,27 @@ int main(int argc, char **argv) ...@@ -657,27 +670,27 @@ int main(int argc, char **argv)
retry=0; retry=0;
ratio=(insize-outsize)*100.0/insize; ratio=(insize-outsize)*100.0/insize;
printf("%ld --> %ld bytes (%0.2f%%), ",insize,outsize,ratio); if (!quiet_mode) printf("%ld --> %ld bytes (%0.2f%%), ",insize,outsize,ratio);
average_count++; average_count++;
average_rate+=(ratio<0 ? 0.0 : ratio); average_rate+=(ratio<0 ? 0.0 : ratio);
if ((outsize < insize && ratio >= threshold) || force) { if ((outsize < insize && ratio >= threshold) || force) {
total_save+=(insize-outsize)/1024.0; total_save+=(insize-outsize)/1024.0;
printf("optimized.\n"); if (!quiet_mode) printf("optimized.\n");
if (noaction) continue; if (noaction) continue;
if (verbose_mode > 1 && !quiet_mode) if (verbose_mode > 1 && !quiet_mode)
fprintf(stderr,"renaming: %s to %s\n",outfname,newname); fprintf(stderr,"renaming: %s to %s\n",outfname,newname);
if (rename(outfname,newname)) fatal("cannot rename temp file"); if (rename(outfname,newname)) fatal("cannot rename temp file");
} else { } else {
printf("skipped.\n"); if (!quiet_mode) printf("skipped.\n");
if (!noaction) delete_file(outfname); if (!noaction) delete_file(outfname);
} }
} while (++i<argc); } while (++i<argc);
if (totals_mode&&!quiet_mode) if (totals_mode && !quiet_mode)
printf("Average ""compression"" (%ld files): %0.2f%% (%0.0fk)\n", printf("Average ""compression"" (%ld files): %0.2f%% (%0.0fk)\n",
average_count, average_rate/average_count, total_save); average_count, average_rate/average_count, total_save);
jpeg_destroy_decompress(&dinfo); jpeg_destroy_decompress(&dinfo);
......
Summary: Utility for optimizing/compressing JPEG files. Summary: Utility for optimizing/compressing JPEG files.
Name: jpegoptim Name: jpegoptim
Version: 1.2.3 Version: 1.2.5
Release: 1 Release: 1
License: GPL License: GPL
Group: Applications/Multimedia Group: Applications/Multimedia
......
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