Commit 4876b0b 1 parent 61deab3 commit 4876b0b Copy full SHA for 4876b0b
File tree 2 files changed +18
-5
lines changed
2 files changed +18
-5
lines changed Original file line number Diff line number Diff line change @@ -337,6 +337,17 @@ Recommended use is with '-o max' and '--fast'.")
337
337
. long ( "zopfli" )
338
338
. action ( ArgAction :: SetTrue ) ,
339
339
)
340
+ . arg (
341
+ Arg :: new ( "iterations" )
342
+ . help ( "Number of Zopfli iterations [default: 15]" )
343
+ . long_help ( "\
344
+ Set the number of iterations to use for Zopfli compression. The default number of \
345
+ iterations is 15. Using fewer iterations may speed up compression for large files. This \
346
+ option requires '--zopfli' to be set.")
347
+ . long ( "zi" )
348
+ . value_parser ( 1 ..=255 )
349
+ . requires ( "zopfli" ) ,
350
+ )
340
351
. arg (
341
352
Arg :: new ( "timeout" )
342
353
. help ( "Maximum amount of time to spend on optimizations" )
Original file line number Diff line number Diff line change @@ -324,12 +324,14 @@ fn parse_opts_into_struct(
324
324
opts. strip = StripChunks :: Safe ;
325
325
}
326
326
327
+ #[ cfg( feature = "zopfli" ) ]
327
328
if matches. get_flag ( "zopfli" ) {
328
- #[ cfg( feature = "zopfli" ) ]
329
- if let Some ( iterations) = NonZeroU8 :: new ( 15 ) {
330
- opts. deflate = Deflaters :: Zopfli { iterations } ;
331
- }
332
- } else if let ( Deflaters :: Libdeflater { compression } , Some ( x) ) =
329
+ let iterations = * matches. get_one :: < i64 > ( "iterations" ) . unwrap_or ( & 15 ) ;
330
+ opts. deflate = Deflaters :: Zopfli {
331
+ iterations : NonZeroU8 :: new ( iterations as u8 ) . unwrap ( ) ,
332
+ } ;
333
+ }
334
+ if let ( Deflaters :: Libdeflater { compression } , Some ( x) ) =
333
335
( & mut opts. deflate , matches. get_one :: < i64 > ( "compression" ) )
334
336
{
335
337
* compression = * x as u8 ;
You can’t perform that action at this time.
0 commit comments