Availability::- use_module(library(zlib)).(can be autoloaded)
zopen(+Stream, -ZStream, +Options)
Creates ZStream, providing compressed access to Stream. If an input stream is wrapped, it recognises a gzip or deflate header.

If an output stream is enabled, Options define the desired wrapper and compression level. Defined options on output streams are:

format(+Format)
Either deflate (default) or gzip. The deflate envelope is simple and short and is typically used for compressed (network) communication. The gzip envelope is compatible to the gzip program and intended to read/write compressed files.
level(+Level)
Number between 0 and 9, specifying the compression level, Higher levels use more resources. Default is 6, generally believed to be a good compromise between speed, memory requirement and compression.

Generic options are:

close_parent(Bool)
If true (default), closing the compressed stream also closes (and thus invalidates) the wrapped stream. If false, the wrapped stream is not closed. This can be used to read/write a compressed ndata block as partial input/output on a stream.