estimateCompressedSize

fnsize_t estimateCompressedSize(CompressionFormat fmt, size_t inputSize)

Estimate maximum compressed size for given input size.

Returns an upper bound suitable for pre-allocating output buffers.

Note

Incompressible data may expand; this returns worst-case size.

Parameters

fmtThe compression format to estimate for
inputSizeSize of the uncompressed input data in bytes

Returns

Upper bound estimate of compressed size in bytes

Examples

---

// Pre-allocate buffer for GZIP compression auto inputData = cast(ubyte[])"Hello, World!"; auto bufferSize = estimateCompressedSize(CompressionFormat.GZIP, inputData.length); auto outputBuffer = new ubyte[](bufferSize); ---