11 use IO::Compress::Brotli;
12 use IO::Uncompress::Brotli;
15 'c|custom-dictionary=s' => \(my $DICTIONARY),
16 'd|decompress' => \(my $DECOMPRESS),
17 'h|help' => \(my $HELP),
18 'i|input=s' => \(my $INPUT),
19 'o|output=s' => \(my $OUTPUT),
20 'q|quality=i' => \(my $QUALITY = 11),
21 'r|repeat=i' => \(my $REPEAT),
22 's|stream=i' => \(my $STREAM),
23 'v|verbose' => \(my $VERBOSE),
24 'w|window=i' => \(my $WINDOW = 22),
28 say "Usage: $0 [--force] [--quality n] [--decompress] [--input filename] [--output filename]".
29 " [--repeat iters] [--verbose] [--window n] [--custom-dictionary filename] [--stream size]";
33 my ($ifh, $ofh) = (\*STDIN, \*STDOUT);
36 open $ifh, "<", $INPUT
37 or die "Cannot open input file $INPUT.\n";
42 open $ofh, ">", $OUTPUT
43 or die "Cannot open output file $OUTPUT.\n";
49 my $brotli = IO::Uncompress::Brotli->create();
50 while( read $ifh, (my $buf), $STREAM ) {
51 print $ofh $brotli->decompress($buf);
55 my $encoded = read_file( $ifh );
56 my $decoded = unbro( $encoded );
57 write_file( $ofh, $decoded );
62 my $brotli = IO::Compress::Brotli->create();
63 $brotli->quality( $QUALITY );
64 $brotli->window( $WINDOW );
65 while( read $ifh, (my $buf), $STREAM ) {
66 print $ofh $brotli->compress($buf);
70 my $decoded = read_file( $ifh );
71 my $encoded = bro( $decoded, $QUALITY, $WINDOW );
72 write_file( $ofh, $encoded );