DeflOpt.txt 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. DeflOpt 2.07 of 05-Sep-2007
  2. Copyright (C) 2003-2007 by Ben Jos Walbeehm
  3. Some additional information regarding DeflOpt. I chose to put this in a text
  4. file, because I did not want to make the built-in help multiple pages long.
  5. First of all, for those who wish to contact me through e-mail: I get well over
  6. 100 spam e-mails every day and because of that my own SpamKill program uses
  7. VERY aggressive settings. To circumvent that, make sure to put "DeflOpt" in
  8. the subject line when sending me an e-mail. The address is:
  9. walbeehm AT walbeehm DOT com.
  10. (From the built-in help)
  11. *** DeflOpt V2.07 ***
  12. *** Built on Wed Sep 5 18:56:30 2007 ***
  13. *** Copyright (C) 2003-2007 by Ben Jos Walbeehm ***
  14. Description:
  15. DeflOpt tries to reduce the size of GZIP (extensions .gz and .tgz), PNG, and
  16. ZIP files. Regardless of which programs/settings were used to create them,
  17. DeflOpt will usually be able to reduce these files by at least a few bytes.
  18. Parameters:
  19. [options] <filespec> [<filespec> [<filespec> ...]]
  20. Available options:
  21. /a: Scans all files that match the specifications to determine whether they
  22. are in a supported format (GZIP, PNG, ZIP), regardless of extensions.
  23. /b: Replaces files also when no bytes, but more than zero bits were saved.
  24. /d: Preserves the date and time of files it rewrites.
  25. /c: Comments in GZIP and ZIP files are kept. By default, these are removed.
  26. /f: Forces every file to be rewritten, even when no bits/bytes were saved.
  27. /k: Keeps all chunks/structures within files, even the mostly useless ones.
  28. /r: Recursively go through all subdirectories.
  29. /s: Silent mode. Nothing is displayed except in case of errors.
  30. /v: Verbose output.
  31. Notes (for more detailed information, see DeflOpt.txt):
  32. - Options may be specified using both slashes ("/") and dashes ("-").
  33. - Wildcards * and ? are allowed, including in directory names.
  34. - For directories, all GZIP, PNG, and ZIP files in those directories are
  35. processed.
  36. - If <filespec> has no extension, .gz, .tgz, .png, and .zip are used, unless
  37. the /a option is specified -- in that case, DeflOpt will scan every file to
  38. determine the format and process every file accordingly.
  39. - DeflOpt will NOT process GZIP, PNG, and ZIP files WITHIN (G)ZIP files.
  40. - By default, DeflOpt rewrites a file only when it can reduce the number of
  41. bytes of that file. It is possible that DeflOpt makes the deflated data
  42. one or more bits shorter but that this does not make the size in bytes less.
  43. Use the /b option to have DeflOpt rewrite files also when it can only
  44. save one or more bits but no actual bytes.
  45. Examples:
  46. DeflOpt /r *.zip abc*.png
  47. DeflOpt -K "C:\Documents and Settings\Ben Jos\My Documents\My Pictures"
  48. DeflOpt ..\..\stuff -b/c/k /FrS
  49. DeflOpt /adr C:\Prog* /f
  50. (End of From the built-in help)
  51. As its name implies (DeflOpt -- Deflate Optimisation), DeflOpt will not try to
  52. optimise files that use a type of compression different from LZ77 ("Deflate").
  53. It will also not process files compressed with the "Deflate64" type. Unlike
  54. the 1.XX versions of DeflOpt, versions 2.XX and above will not exit with an
  55. error message, but simply copy the compressed data of the types it does not
  56. "understand".
  57. As the examples show, options are case-insensitive and do not have to be
  58. separated by spaces, nor does the slash ("/") or dash ("-") even have to be
  59. repeated. For instance: "/b /c /f", "/b/c/f", and "/bcf" all mean the same.
  60. Regarding /a: By default, DeflOpt will only process files that have one of
  61. the extensions .gz, .png, .tgz, and .zip, and will assume that those files
  62. are valid. So if a ZIP file has the extension .png, DeflOpt will most likely
  63. fail with an error message. However, if /a is specified, then DeflOpt will
  64. scan all files that match the specifications to see if they are in any of
  65. the supported formats (GZIP, PNG, ZIP). This of course makes DeflOpt slower,
  66. but also smarter. Since there are many other extensions that are really just
  67. GZIP, PNG, or ZIP files, using /a will process those files too. In addition,
  68. if a file has the wrong extension (for instance a ZIP file that has the
  69. extension .png), then DeflOpt will still treat it correctly.
  70. Regarding /b: Bit gain vs. byte gain: In a zip file, technically it is
  71. possible to gain one bit per file for 8 files and save a total of 8 BYTEs.
  72. At the same time, it is possible to save 7 bits per file for 8 files, but not
  73. save a single byte.
  74. Regarding /f: The resulting file will never be larger than the input file.
  75. However, the resulting file may be slightly different, because DeflOpt always
  76. does certain things to make sure that certain fields do not have invalid
  77. values (CRCs, for instance).
  78. Regarding /k: Several structures within files are optional. By default,
  79. DeflOpt does not keep structures that are optional or mostly useless.
  80. What is optional or mostly useless depends on the file type:
  81. - For GZIP files: By default, only the original filename (if any) is kept
  82. (yes, I know it is optional, but it is "important enough to be kept"). The
  83. extra-text, comment, and 16-bit-CRC fields are only kept if /k is specified.
  84. Note that the comment is also kept if /c is specified.
  85. - For PNG files: By default, only IDAT, IEND, IHDR, PLTE, and tRNS chunks are
  86. kept. Specify /k to keep all other chunk types as well. If /k is specified,
  87. then DeflOpt will try to improve deflated data in iCCP, iTXt, and zTXt
  88. chunks as well. Note that when a PNG file contains multiple IDAT chunks,
  89. these will always be combined into one because there is absolutely no need
  90. to divide the compressed data over multiple IDAT chunks.
  91. - For ZIP files: By default, no optional fields are kept, so unless /k is
  92. specified, the optional fields zip-comment, file-comment, digital-signature,
  93. central-extra-field, and local-extra-field are not kept. Note that both
  94. types of comment fields will still be kept if /c is specified. Note that
  95. stored directory names within ZIP files as well as "Data Descriptors" will
  96. ALWAYS be removed, REGARDLESS of whether /k is specified or not. Both are
  97. ALWAYS redundant: The first because those directory names are also part of
  98. the filenames and every unzip program these days will create the necessary
  99. directories. The second because DeflOpt will store the necessary information
  100. directly in the local and central directory entries inside the ZIP file.
  101. "Data Descriptors" are only useful when the actual uncompressed size,
  102. compressed size, and 32-bit CRC are not yet known while compressing data;
  103. in other words, while piping/streaming data.
  104. Regarding /s and /v: These two options are mutually exclusive. If both are
  105. specified, then the one specified last will count.
  106. Regarding wildcards:
  107. Wildcards * and ? are allowed in directory names as well. However, unless /r
  108. ("recursive") is specified, wildcards will not match subdirectories of the
  109. directory that has the wildcards. So the file C:\TEMP\EXAMPLE\test.zip will
  110. only be processed by "C:\TEM*\*.zip" in case /r is specified. If /r is not
  111. specified, then it will only look for anything matching *.zip in the C:\TEMP
  112. directory and (if any) other directories that have a name starting with
  113. "C:\TEM", but not subdirectories of those directories. Because of the very
  114. powerful wildcards, DeflOpt will ONLY look at files that have one of the
  115. extensions .gz, .png, .tgz, and .zip, UNLESS /a is specified. So if there is
  116. a file called "c:\temp.txt", running "DeflOpt c:\temp.txt" will NOT process
  117. that file. Note, however, that if there were a "c:\temp.txt" DIRECTORY, then
  118. DeflOpt would look at all .gz, .png, .tgz and .zip files in that directory.
  119. If all the .gz and .tgz files in the current directory should be processed,
  120. but not the .png and .zip files, then use something like "DeflOpt *.gz *.tgz".
  121. Since wildcards can be used for both directories and files, this means that
  122. the "*" in "DeflOpt C:\TEST\*" will match both files and directories. Some
  123. examples of this:
  124. "DeflOpt C:\TEST\*"
  125. This will process all the files in the C:\TEST directory as well as all the
  126. files in any of its subdirectories (but not THEIR subdirectories unless /r
  127. is specified). So the file C:\TEST\EXAMPLE\test.zip would be processed.
  128. "DeflOpt C:\TEST" (or "DeflOpt C:\TEST\.")
  129. This will process only the files in the C:\TEST directory.
  130. "DeflOpt C:\TEST\*\"
  131. This will process only the files in any of the subdirectories of the C:\TEST
  132. directory (but not THEIR subdirectories unless /r is specified).
  133. "DeflOpt *"
  134. This will process all the files in the current directory as well as all the
  135. files in any of its subdirectories (but not THEIR subdirectories unless /r
  136. is specified).
  137. "DeflOpt ." (or "DeflOpt .\")
  138. This will process only the files in the current directory.
  139. "DeflOpt *\"
  140. This will process only the files in any of the subdirectories of the current
  141. directory (but not THEIR subdirectories unless /r is specified).
  142. By default, DeflOpt will only look at the extension to decide what kind of file
  143. it is dealing with, so if, for example, a GZIP file has the extension .zip, then
  144. DeflOpt will mostly likely exit with an error message. However, in case /a is
  145. specified, then DeflOpt will scan every file matching the specifications to see
  146. if they are in a supported format and process the ones that are.
  147. Short history:
  148. The first version of DeflOpt (V1.00) dates back to 04-Apr-2003. In short
  149. succession, many more versions followed until V1.16, which was created on
  150. 22-Apr-2003. V1.16 was the first public version, although it was not publicly
  151. released until 27-Jun-2003.
  152. After that, development slowed down: V1.17 was created on 07-Sep-2003, V1.18
  153. on 15-Dec-2003, and V1.19 on 23-Feb-2004. I stopped development on DeflOpt
  154. very soon after having created V1.19, and that was part of the reason that
  155. V1.19 was not actually released publicly until more than 2 years afterwards.
  156. V2.00 of 10-Jul-2006:
  157. - Added GZIP (.gz and .tgz) and PNG support, in addition to ZIP support.
  158. - Even better optimisation. V2.00 gets a few more extra bytes out of a
  159. deflated file than V1.19 did, both because of better optimisation and
  160. because of additional removals of optional/useless structures.
  161. - No more exiting with an error message on unsupported ZIP compression methods
  162. (like Implode, Shrink, Reduce, Deflate64, etc.). Unsupported methods are
  163. simply copied without any attempt at optimisation.
  164. - More flexible wildcard matching, allowing wildcards to not just be part of
  165. the actual filenames, but also of directory names.
  166. - More options/switches.
  167. - By default, all "optional" and "mostly useless" structures/chunks are thrown
  168. away now, but /k can be specified to keep everything.
  169. - Stored directory names within ZIP files as well as "Data Descriptors" are
  170. always removed.
  171. - The /n option ("do not actually write any files") is gone.
  172. V2.01 of 15-Jul-2006:
  173. - Fixed the occasional "Compressed size is larger than it was!?!?!?" error.
  174. - Fixed a problem with stored blocks.
  175. - Added the /s option ("silent mode").
  176. V2.02 of 17-Jul-2006:
  177. - Significantly faster (2-6 times or more, depending on the input).
  178. V2.03 of 16-Nov-2006:
  179. - Fixed a very rare Access Violation.
  180. - Fixed a problem with zip files containing data descriptors.
  181. V2.04 of 20-Nov-2006:
  182. - Safer handling of zip files containing data descriptors.
  183. - Fixed a problem with zero-length files that have a compression method
  184. differing from "stored".
  185. V2.05 of 10-Mar-2007:
  186. - Fixed a problem of temporary files not always being deleted.
  187. V2.06 of 28-Apr-2007:
  188. - In very rare cases, DeflOpt would stop parsing compressed data before
  189. encountering the "End Of Block" marker. Fixed.
  190. V2.07 of 05-Sep-2007:
  191. - Added the /a option ("scan all files").
  192. - Added the /d option ("preserve date and time").