Sample code for 30+ languages & platforms
Chilkat2-Python

Decompress Bytes

See more Compression Examples

Demonstrates how to decompress binary data.

Chilkat Chilkat2-Python Downloads

Chilkat2-Python
import sys
import chilkat2

success = False

# This example requires the Chilkat API to have been previously unlocked.
# See Global Unlock Sample for sample code.

# See this example to compress bytes: Compress Bytes

fac = chilkat2.FileAccess()

# compressedBytes is a memoryview
compressedBytes = fac.ReadEntireFile("qa_data/compressed/compressedBmp.dat")
if (fac.LastMethodSuccess != True):
    print(fac.LastErrorText)
    sys.exit()

compress = chilkat2.Compression()
compress.Algorithm = "deflate"

# decompressedBytes is a memoryview
decompressedBytes = compress.DecompressBytes(compressedBytes)
if (compress.LastMethodSuccess != True):
    print(compress.LastErrorText)
    sys.exit()

success = fac.WriteEntireFile("qa_output/decompressed.bmp",decompressedBytes)
if (fac.LastMethodSuccess != True):
    print(fac.LastErrorText)
    sys.exit()