Documentation ¶
Overview ¶
Package lzw is derived from compress/lzw in order to implement Adobe's PDF lzw compression as defined for the LZWDecode filter. See https://www.adobe.com/content/dam/acom/en/devnet/pdf/pdfs/PDF32000_2008.pdf and https://github.com/golang/go/issues/25409.
Copyright 2011 The Go Authors. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
Package lzw implements the Lempel-Ziv-Welch compressed data format, described in T. A. Welch, “A Technique for High-Performance Data Compression”, Computer, 17(6) (June 1984), pp 8-19.
In particular, it implements LZW as used by the GIF and PDF file formats, which means variable-width codes up to 12 bits and the first two non-literal codes are a clear code and an EOF code.
The TIFF file format uses a similar but incompatible version of the LZW algorithm. See the golang.org/x/image/tiff/lzw package for an implementation.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewReader ¶
func NewReader(r io.Reader, oneOff bool) io.ReadCloser
NewReader creates a new io.ReadCloser. Reads from the returned io.ReadCloser read and decompress data from r. If r does not also implement io.ByteReader, the decompressor may read more data than necessary from r. It is the caller's responsibility to call Close on the ReadCloser when finished reading. oneOff makes code length increases occur one code early. It should be true for LZWDecode filters with earlyChange=1 which is also the default.
func NewWriter ¶
func NewWriter(w io.Writer, oneOff bool) io.WriteCloser
NewWriter creates a new io.WriteCloser. Writes to the returned io.WriteCloser are compressed and written to w. It is the caller's responsibility to call Close on the WriteCloser when finished writing. oneOff makes code length increases occur one code early. It should be true for LZWDecode filters with earlyChange=1 which is also the default.