diff --git a/deft4j-cmd/src/main/java/com/github/NeRdTheNed/deft4j/cmd/CMDUtil.java b/deft4j-cmd/src/main/java/com/github/NeRdTheNed/deft4j/cmd/CMDUtil.java index f88f7e8..1e0e18c 100644 --- a/deft4j-cmd/src/main/java/com/github/NeRdTheNed/deft4j/cmd/CMDUtil.java +++ b/deft4j-cmd/src/main/java/com/github/NeRdTheNed/deft4j/cmd/CMDUtil.java @@ -40,11 +40,15 @@ public enum RecompressMode { private final CompressionUtil compUtil; - CMDUtil(RecompressMode recompressMode) { + CMDUtil(RecompressMode recompressMode, int passes) { recompress = recompressMode.ordinal() > RecompressMode.NONE.ordinal(); final boolean zopfli = recompressMode.ordinal() >= RecompressMode.ZOPFLI.ordinal(); final Strategy strat = recompressMode.ordinal() >= RecompressMode.ZOPFLI_EXTENSIVE.ordinal() ? Strategy.EXTENSIVE : Strategy.MULTI_CHEAP; - compUtil = recompress ? new CompressionUtil(true, true, recompressMode.ordinal() >= RecompressMode.ZOPFLI_VERY_EXTENSIVE.ordinal(), zopfli, strat, true, true) : null; + compUtil = recompress ? new CompressionUtil(true, true, recompressMode.ordinal() >= RecompressMode.ZOPFLI_VERY_EXTENSIVE.ordinal(), zopfli, passes, strat, true, true) : null; + } + + CMDUtil(RecompressMode recompressMode) { + this(recompressMode, 20); } /** Read from the given input stream into the container, optimise, and write to the output stream */ diff --git a/deft4j-cmd/src/main/java/com/github/NeRdTheNed/deft4j/cmd/Optimise.java b/deft4j-cmd/src/main/java/com/github/NeRdTheNed/deft4j/cmd/Optimise.java index c944541..209c5fe 100644 --- a/deft4j-cmd/src/main/java/com/github/NeRdTheNed/deft4j/cmd/Optimise.java +++ b/deft4j-cmd/src/main/java/com/github/NeRdTheNed/deft4j/cmd/Optimise.java @@ -27,9 +27,12 @@ class Optimise implements Callable { @Option(names = { "--recompress-mode", "--mode", "-m" }, defaultValue = "NONE", description = "Enable various levels of recompression. Default: ${DEFAULT-VALUE}. Valid values: ${COMPLETION-CANDIDATES}") private RecompressMode recompressMode; + @Option(names = { "--zopfli-iter", "--iter", "-I" }, defaultValue = "20", description = "Zopfli iterations. More iterations increases time spent optimising files.") + int recompressZopfliPasses = 20; + @Override public Integer call() throws Exception { - final CMDUtil deft = new CMDUtil(recompressMode); + final CMDUtil deft = new CMDUtil(recompressMode, recompressZopfliPasses); final boolean didOpt; try { diff --git a/deft4j-cmd/src/main/java/com/github/NeRdTheNed/deft4j/cmd/OptimiseFolder.java b/deft4j-cmd/src/main/java/com/github/NeRdTheNed/deft4j/cmd/OptimiseFolder.java index c5d06d9..2fa23a7 100644 --- a/deft4j-cmd/src/main/java/com/github/NeRdTheNed/deft4j/cmd/OptimiseFolder.java +++ b/deft4j-cmd/src/main/java/com/github/NeRdTheNed/deft4j/cmd/OptimiseFolder.java @@ -24,9 +24,12 @@ class OptimiseFolder implements Callable { @Option(names = { "--recompress-mode", "--mode", "-m" }, defaultValue = "NONE", description = "Enable various levels of recompression. Default: ${DEFAULT-VALUE}. Valid values: ${COMPLETION-CANDIDATES}") private RecompressMode recompressMode; + @Option(names = { "--zopfli-iter", "--iter", "-I" }, defaultValue = "20", description = "Zopfli iterations. More iterations increases time spent optimising files.") + int recompressZopfliPasses = 20; + @Override public Integer call() throws Exception { - final CMDUtil deft = new CMDUtil(recompressMode); + final CMDUtil deft = new CMDUtil(recompressMode, recompressZopfliPasses); boolean didOpt = true; try