FrenchCurve.Deflate (FrenchCurve v0.2.0)

Copy Markdown View Source

Compresses a picture into the zlib format a terminal expects, with libdeflate where it is built and :zlib where it is not.

FrenchCurve.Deflate.compress(pixels)
FrenchCurve.Deflate.compress(pixels, 6)

The kitty graphics protocol takes its payload deflated and marked o=z, which means the zlib wrapper of RFC 1950 rather than a bare deflate stream. Both paths here produce that, so a terminal cannot tell them apart; they differ only in how long they take and how small they get.

level runs 1 to 12 for libdeflate and is clamped to 1..9 for :zlib, which has no levels above nine. Higher is smaller and slower. The default, 6, is what :zlib.compress/1 uses.

available?/0 says whether libdeflate is in use.

Summary

Functions

Whether libdeflate is built and loaded.

data compressed into the zlib format, at level.

Functions

available?()

@spec available?() :: boolean()

Whether libdeflate is built and loaded.

compress(data, level \\ 6)

@spec compress(binary(), 1..12) :: binary()

data compressed into the zlib format, at level.