summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGlenn Randers-Pehrson <glennrp at users.sourceforge.net>2000-01-14 06:31:05 -0600
committerGlenn Randers-Pehrson <glennrp at users.sourceforge.net>2009-04-16 10:46:40 -0500
commitf1425677258ee297b861e26a4e92450087649848 (patch)
tree401d26ae1ca87b2cf89c3e7cb349ce5e3e4f51ad
parent10ecaa7a20ce62a49a20f4dc9dfb6d5046658127 (diff)
downloadlibpng-f1425677258ee297b861e26a4e92450087649848.tar.gz
Imported from pngcrush-1.3.4.tarv1.3.4
-rw-r--r--README.txt27
-rw-r--r--pngcrush.c50
2 files changed, 55 insertions, 22 deletions
diff --git a/README.txt b/README.txt
index 289f2c095..cec2ae962 100644
--- a/README.txt
+++ b/README.txt
@@ -29,10 +29,11 @@ This is the copyright notice, disclaimer, and license:
This is the output of "pngcrush" and "pngcrush -help":
- | pngcrush 1.3.2, Copyright (C) 1998, 1999, Glenn Randers-Pehrson
+
+ | pngcrush 1.3.4, Copyright (C) 1998, 1999, 2000, Glenn Randers-Pehrson
| This is a free, open-source program. Permission is
| granted to everyone to use pngcrush without fee.
- | This program was built with libpng version 1.0.5k,
+ | This program was built with libpng version 1.0.5m,
| Copyright (C) 1995, Guy Eric Schalnat, Group 42 Inc.,
| Copyright (C) 1996, 1997 Andreas Dilger,
| Copyright (C) 1998, 1999, Glenn Randers-Pehrson,
@@ -45,15 +46,15 @@ usage: pngcrush [options] infile.png outfile.png
pngcrush -d dir [other options] files.png ...
options:
- -brute (Use brute-force, try 114 different methods)
+ -brute (Use brute-force, try 114 different methods [11-124])
-c color_type of output file [0, 2, 4, or 6]
-d directory_name (where output files will go)
-double_gamma (used for fixing gamma in PhotoShop 5.0/5.02 files)
-e extension (used for creating output filename)
-f user_filter [0-5]
-force (Write a new output file even if larger than input)
- -g gamma_value (float, e.g., 0.45455)
- -itxt b[efore_IDAT]|a[fter_IDAT] "keyword" "text"
+ -g gamma (float or fixed*100000, e.g., 0.45455 or 45455)
+ -itxt b[efore_IDAT]|a[fter_IDAT] "keyword" "text"
-l zlib_compression_level [0-9]
-m method [0 through 200]
-max maximum_IDAT_size [1 through 524288]
@@ -66,14 +67,14 @@ options:
-srgb [0, 1, 2, or 3]
-text b[efore_IDAT]|a[fter_IDAT] "keyword" "text"
-trns index red green blue gray
- -verbose (write more detailed information)
+ -v (display more detailed information)
+ -version (display the pngcrush version)
-w compression_window_size [32, 16, 8, 4, 2, 1, 512]
-h (help)
-p (pause)
-
options:
- -brute (Use brute-force, try 114 different methods)
+ -brute (Use brute-force, try 114 different methods [11-124])
Very time-consuming and generally not worthwhile.
You can restrict this option to certain filter types,
@@ -120,13 +121,13 @@ options:
if it is smaller than any generated file and no chunk
additions, removals, or changes were requested.
- -g gamma_value (float, e.g., 0.45455)
+ -g gamma (float or fixed*100000, e.g., 0.45455 or 45455)
Value to insert in gAMA chunk, only if the input
file has no gAMA chunk. To replace an existing
gAMA chunk, use the '-replace_gamma' option.
- -itxt b[efore_IDAT]|a[fter_IDAT] "keyword" "text"
+ -itxt b[efore_IDAT]|a[fter_IDAT] "keyword" "text"
Compressed iTXt chunk to insert (see -text).
@@ -199,10 +200,12 @@ options:
You must give all five parameters regardless of the
color type, scaled to the output bit depth.
- -verbose (write more detailed information)
+ -v (display more detailed information)
Repeat the option (use "-v -v") for even more.
+ -version (display the pngcrush version)
+
-w compression_window_size [32, 16, 8, 4, 2, 1, 512]
Size of the sliding compression window, in kbytes
@@ -216,7 +219,7 @@ options:
zlib compression strategy to use with the preceding
'-m method' argument.
- -zitxt b[efore_IDAT]|a[fter_IDAT] "keyword" "text"
+ -zitxt b[efore_IDAT]|a[fter_IDAT] "keyword" "text"
Compressed iTXt chunk to insert (see -text).
diff --git a/pngcrush.c b/pngcrush.c
index 8a9f97d70..c55a63783 100644
--- a/pngcrush.c
+++ b/pngcrush.c
@@ -15,12 +15,12 @@
* occasionally creating Linux executables.
*/
-#define PNGCRUSH_VERSION "1.3.3"
+#define PNGCRUSH_VERSION "1.3.4"
/*
* COPYRIGHT NOTICE, DISCLAIMER, AND LICENSE:
*
- * Copyright (c) 1998, 1999, Glenn Randers-Pehrson (randeg@alum.rpi.edu)
+ * Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson (randeg@alum.rpi.edu)
*
* The pngcrush program is supplied "AS IS". The Author disclaims all
* warranties, expressed or implied, including, without limitation, the
@@ -54,6 +54,10 @@
*
* Change log:
*
+ * Version 1.3.4 (built with libpng-1.0.5m)
+ *
+ * Do not allow pngcrush to overwrite the input file.
+ *
* Version 1.3.3 (built with libpng-1.0.5m)
*
* Restored ability to enter gamma as a float even when floating point
@@ -175,6 +179,9 @@
static PNG_CONST char *progname = "pngtest.png";
static PNG_CONST char *inname = "pngtest.png";
static PNG_CONST char *outname = "pngout.png";
+#if 0
+static PNG_CONST char *tmpname = "pngtmp.png";
+#endif
static PNG_CONST char *directory_name = "pngcrush.bak";
static PNG_CONST char *extension = "_C.png";
@@ -527,6 +534,9 @@ main(int argc, char *argv[])
png_fixed_point file_gamma=0;
#endif
char *cp;
+#if 0
+ FILE *tmpfile (void);
+#endif
int i;
row_buf = (png_bytep)NULL;
@@ -992,7 +1002,7 @@ main(int argc, char *argv[])
if(verbose > 0)
{
fprintf(STDERR,
- "\n | %s %s, Copyright (C) 1998, 1999, Glenn Randers-Pehrson\n",
+ "\n | %s %s, Copyright (C) 1998, 1999, 2000 Glenn Randers-Pehrson\n",
progname, PNGCRUSH_VERSION);
fprintf(STDERR, " | This is a free, open-source program. Permission is\n");
fprintf(STDERR, " | granted to everyone to use pngcrush without fee.\n");
@@ -1004,7 +1014,7 @@ main(int argc, char *argv[])
fprintf(STDERR,
" | Copyright (C) 1996, 1997 Andreas Dilger,\n");
fprintf(STDERR,
- " | Copyright (C) 1998, 1999, Glenn Randers-Pehrson,\n");
+ " | Copyright (C) 1998, 1999, 2000 Glenn Randers-Pehrson,\n");
fprintf(STDERR,
" | and zlib version %s, Copyright (c) 1998,\n",
ZLIB_VERSION);
@@ -1531,6 +1541,7 @@ main(int argc, char *argv[])
if(idat_length[best] == idat_length[0] && things_have_changed == 0
&& best != final_method && nosave == 0)
{
+ struct stat stat_in, stat_out;
/* just copy input to output */
if(verbose > 2)
@@ -1542,6 +1553,7 @@ main(int argc, char *argv[])
fprintf(STDERR, "Could not find input file %s\n", inname);
return 1;
}
+
number_of_open_files++;
if ((fpout = FOPEN(outname, "wb")) == NULL)
{
@@ -1549,18 +1561,25 @@ main(int argc, char *argv[])
FCLOSE(fpin);
return 1;
}
+
number_of_open_files++;
if(verbose > 2)
printf("copying input to output...");
- for(;;)
+
+ stat(inname, &stat_in);
+ stat(outname, &stat_out);
+ if(stat_in.st_ino != stat_out.st_ino)
{
- png_size_t num_in;
+ for(;;)
+ {
+ png_size_t num_in;
- num_in = fread(buffer, 1, 1, fpin);
- if (!num_in)
- break;
- fwrite(buffer, 1, 1, fpout);
+ num_in = fread(buffer, 1, 1, fpin);
+ if (!num_in)
+ break;
+ fwrite(buffer, 1, 1, fpout);
+ }
}
if(verbose > 2)
printf("copy complete.\n");
@@ -1618,12 +1637,23 @@ main(int argc, char *argv[])
number_of_open_files++;
if(nosave == 0)
{
+ struct stat stat_in, stat_out;
+ stat(inname, &stat_in);
+ stat(outname, &stat_out);
+ if(stat_in.st_ino == stat_out.st_ino)
+ {
+ fprintf(STDERR, "Cannot overwrite input file %s\n", inname);
+ FCLOSE(fpin);
+ return 1;
+ }
+
if ((fpout = FOPEN(outname, "wb")) == NULL)
{
fprintf(STDERR, "Could not open output file %s\n", outname);
FCLOSE(fpin);
return 1;
}
+
number_of_open_files++;
}