|
1 | 1 | # Zippy |
2 | | -Easy Compression in PowerShell |
| 2 | +[](https://www.powershellgallery.com/packages/Zippy/) |
| 3 | +## Easy Compression in PowerShell |
| 4 | +Zippy is a quick compression module. |
| 5 | + |
| 6 | +* `Compress-Zippy` compresses content |
| 7 | +* `Expand-Zippy` expands contents |
| 8 | + |
| 9 | +Zippy currently supports four compression algorithms: |
| 10 | + |
| 11 | +* [Brotli](https://learn.microsoft.com/en-us/dotnet/api/system.io.compression.brotlistream?wt.mc_id=MVP_321542) |
| 12 | +* [Deflate](https://learn.microsoft.com/en-us/dotnet/api/system.io.compression.deflatestream?wt.mc_id=MVP_321542) |
| 13 | +* [GZip](https://learn.microsoft.com/en-us/dotnet/api/system.io.compression.gzipstream?wt.mc_id=MVP_321542) |
| 14 | +* [Zlib](https://learn.microsoft.com/en-us/dotnet/api/system.io.compression.zlibstream?wt.mc_id=MVP_321542) |
| 15 | + |
| 16 | + |
| 17 | +## Installing and Importing |
| 18 | + |
| 19 | +You can install Zippy from the [PowerShell gallery](https://powershellgallery.com/) |
| 20 | + |
| 21 | +~~~PowerShell |
| 22 | +Install-Module Zippy -Scope CurrentUser -Force |
| 23 | +~~~ |
| 24 | + |
| 25 | +Once installed, you can import the module with: |
| 26 | + |
| 27 | +~~~PowerShell |
| 28 | +Import-Module Zippy -PassThru |
| 29 | +~~~ |
| 30 | + |
| 31 | + |
| 32 | +You can also clone the repo and import the module locally: |
| 33 | + |
| 34 | +~~~PowerShell |
| 35 | +git clone https://github.com/PoshWeb/Zippy |
| 36 | +cd ./Zippy |
| 37 | +Import-Module ./ -PassThru |
| 38 | +~~~ |
| 39 | + |
| 40 | +## Functions |
| 41 | +Zippy has 2 functions |
| 42 | +### Compress-Zippy |
| 43 | +#### Quickly Compresses Content |
| 44 | +Compresses Content using a number of standard algorithms. |
| 45 | + |
| 46 | +* Brotli (default) |
| 47 | +* Default |
| 48 | +* Gzip |
| 49 | +* Zlib |
| 50 | +##### Parameters |
| 51 | + |
| 52 | +|Name|Type|Description| |
| 53 | +|-|-|-| |
| 54 | +|Text|String|The text to compress| |
| 55 | +|Bytes|Byte[]|A range of bytes to compress.| |
| 56 | +|Stream|Stream|A stream to compress.| |
| 57 | +|Algorithm|String|The compression algorithm.<br/>By default, Brotli.| |
| 58 | +|Encoding|Encoding|The text encoding.<br/>By default, this will be the `$outputEncoding`| |
| 59 | +|CompressionLevel|CompressionLevel|The compression level.<br/>By default, this will be `fastest`.| |
| 60 | +|AsByteStream|SwitchParameter|If set, will output a byte stream.<br/>If not set, will output a base64 encoded string.| |
| 61 | + |
| 62 | +##### Examples |
| 63 | +###### Example 1 |
| 64 | +~~~PowerShell |
| 65 | +Compress-Zippy "Hello World" |
| 66 | +~~~ |
| 67 | +###### Example 2 |
| 68 | +~~~PowerShell |
| 69 | +Compress-Zippy "Hello World" -Algorithm Deflate |
| 70 | +~~~ |
| 71 | +###### Example 3 |
| 72 | +~~~PowerShell |
| 73 | +Compress-Zippy "Hello World" -Algorithm GZip |
| 74 | +~~~ |
| 75 | +###### Example 4 |
| 76 | +~~~PowerShell |
| 77 | +Compress-Zippy "Hello World" -Algorithm Zlib |
| 78 | +~~~ |
| 79 | +###### Example 5 |
| 80 | +~~~PowerShell |
| 81 | +Compress-Zippy "Hello World" -Algorithm Brotli -AsByteStream |
| 82 | +~~~ |
| 83 | +###### Example 6 |
| 84 | +~~~PowerShell |
| 85 | +Compress-Zippy "Hello World" -Algorithm Deflate -AsByteStream |
| 86 | +~~~ |
| 87 | +###### Example 7 |
| 88 | +~~~PowerShell |
| 89 | +Compress-Zippy "Hello World" -Algorithm GZip -AsByteStream |
| 90 | +~~~ |
| 91 | +###### Example 8 |
| 92 | +~~~PowerShell |
| 93 | +Compress-Zippy "Hello World" -Algorithm Zlib -AsByteStream |
| 94 | +~~~ |
| 95 | +### Expand-Zippy |
| 96 | +#### Expands Compressed Data |
| 97 | +Expands Compressed Data using the .NET GZipStream class |
| 98 | +##### Parameters |
| 99 | + |
| 100 | +|Name|Type|Description| |
| 101 | +|-|-|-| |
| 102 | +|CompressedData|String|The compressed data, as a Base64 string| |
| 103 | +|BinaryData|Byte[]|The compressed data, as a byte array| |
| 104 | +|AsByteStream|SwitchParameter|If set, will output a `byte[]` of decompressed bytes.| |
| 105 | +|AsBase64|SwitchParameter|If set, will output the decompressed data as a base64 string| |
| 106 | +|Algorithm|String|The compression algorithm.<br/>By default, Brotli.| |
| 107 | +|Encoding|Encoding|The text encoding.<br/>By default, this will be the $outputEncoding| |
| 108 | + |
| 109 | +##### Examples |
| 110 | +###### Example 1 |
| 111 | +~~~PowerShell |
| 112 | +Compress-Zippy -String ("abc" * 1kb) | |
| 113 | + Expand-Zippy |
| 114 | +~~~ |
| 115 | +###### Example 2 |
| 116 | +~~~PowerShell |
| 117 | +Compress-Zippy "Hello World" | Expand-Zippy |
| 118 | +~~~ |
| 119 | +###### Example 3 |
| 120 | +~~~PowerShell |
| 121 | +Compress-Zippy "Hello World" -Algorithm Deflate | |
| 122 | + Expand-Zippy -Algorithm Deflate |
| 123 | +~~~ |
| 124 | +###### Example 4 |
| 125 | +~~~PowerShell |
| 126 | +Compress-Zippy "Hello World" -Algorithm GZip | |
| 127 | + Expand-Zippy -Algorithm GZip |
| 128 | +~~~ |
| 129 | +###### Example 5 |
| 130 | +~~~PowerShell |
| 131 | +Compress-Zippy "Hello World" -Algorithm Zlib | |
| 132 | + Expand-Zippy -Algorithm Zlib |
| 133 | +~~~ |
| 134 | +###### Example 6 |
| 135 | +~~~PowerShell |
| 136 | +Compress-Zippy "Hello World" -Algorithm Brotli -AsByteStream | |
| 137 | + Expand-Zippy |
| 138 | +~~~ |
| 139 | +###### Example 7 |
| 140 | +~~~PowerShell |
| 141 | +Compress-Zippy "Hello World" -Algorithm Deflate -AsByteStream | |
| 142 | + Expand-Zippy -Algorithm Deflate |
| 143 | +~~~ |
| 144 | +###### Example 8 |
| 145 | +~~~PowerShell |
| 146 | +Compress-Zippy "Hello World" -Algorithm GZip -AsByteStream | |
| 147 | + Expand-Zippy -Algorithm GZip |
| 148 | +~~~ |
| 149 | +###### Example 9 |
| 150 | +~~~PowerShell |
| 151 | +Compress-Zippy "Hello World" -Algorithm Zlib -AsByteStream | |
| 152 | + Expand-Zippy -Algorithm Zlib |
| 153 | +~~~ |
0 commit comments