From 0fb6c554f993cac3ca7bea17186da4462d84e9ea Mon Sep 17 00:00:00 2001 From: Glenn Randers-Pehrson Date: Wed, 7 Jan 2009 13:45:55 -0600 Subject: [PATCH] Imported from pngcrush-1.6.13.tar --- ChangeLog.txt | 5 +++++ pngcrush.c | 22 +++++++++++++++++----- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index fa261bd88..220f3189a 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,5 +1,10 @@ Change log: +Version 1.6.13 (built with libpng-1.2.34 and zlib-1.2.3.2) + Added "-time_stamp" directive, to cause pngcrush to write + a new timestamp on the output file instead of replicating + the timestame from the input file. + Version 1.6.12 (built with libpng-1.2.34 and zlib-1.2.3.2) Version 1.6.11 (built with libpng-1.2.33 and zlib-1.2.3.2) diff --git a/pngcrush.c b/pngcrush.c index 71e8f1695..5b5039f39 100644 --- a/pngcrush.c +++ b/pngcrush.c @@ -26,7 +26,7 @@ * */ -#define PNGCRUSH_VERSION "1.6.12" +#define PNGCRUSH_VERSION "1.6.13" /* #define PNGCRUSH_COUNT_COLORS @@ -88,8 +88,6 @@ * * Finish pplt (partial palette) feature. * - * add "-time" directive - * * Allow in-place file replacement or as a filter, as in * "pngcrush -overwrite file.png" * "pngcreator | pngcrush > output.png" @@ -548,6 +546,7 @@ static int best_of_three; static int methods_specified = 0; static int intent = -1; static int ster_mode = -1; +static int new_time_stamp = 0; static int plte_len = -1; #ifdef PNG_FIXED_POINT_SUPPORTED static int specified_gamma = 0; @@ -2116,6 +2115,8 @@ int main(int argc, char *argv[]) #endif } } + else if (!strncmp(argv[i], "-time_stamp", 5)) + new_time_stamp++; #ifdef PNG_tRNS_SUPPORTED else if (!strncmp(argv[i], "-trns_a", 7) || !strncmp(argv[i], "-tRNS_a", 7)) { @@ -4545,7 +4546,7 @@ int main(int argc, char *argv[]) setfiletype(outname); } - if (verbose > 0 && nosave == 0) { + if (nosave == 0) { png_uint_32 input_length, output_length; #ifndef __riscos struct stat stat_buf; @@ -4557,11 +4558,15 @@ int main(int argc, char *argv[]) utim.modtime = stat_buf.st_mtime; stat(outname, &stat_buf); output_length = (unsigned long) stat_buf.st_size; - utime(outname, &utim); /* set timestamp (no big deal if fails) */ + if (new_time_stamp == 0) { + /* set file timestamp (no big deal if fails) */ + utime(outname, &utim); + } #else input_length = (unsigned long) filesize(inname); output_length = (unsigned long) filesize(outname); #endif + if (verbose > 0) { total_input_length += input_length + output_length; if (!already_crushed && !image_is_immutable) { @@ -4589,6 +4594,7 @@ int main(int argc, char *argv[]) fprintf(STDERR, " Number of open files=%d\n", number_of_open_files); + } } if (pngcrush_mode == DEFAULT_MODE) { @@ -5830,6 +5836,12 @@ struct options_help pngcrush_options[] = { {2, " ten tEXt, iTXt, or zTXt chunks per pngcrush run."}, {2, ""}, + {0, " -time_stamp"}, + {2, ""}, + {2, " Reset file modification time. Default is to"}, + {2, " reproduce the input file modification time."}, + {2, ""}, + #ifdef PNG_tRNS_SUPPORTED {0, " -trns_array n trns[0] trns[1] .. trns[n-1]"}, {2, ""},