tiff

package
v0.1.18 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 11, 2018 License: Apache-2.0 Imports: 13 Imported by: 0

README

Note

This package is an improved version of golang.org/x/image/tiff. It uses a consolidated version of compress/lzw (hosted at: github.com/hhrutter/pdfcpu/lzw) for compression and also adds support for CMYK.

Background

As stated in this golang proposal right now Go lzw implementations are spread out over the standard library(compress/lzw) and golang.org/x/image/tiff/lzw. As of go1.11 compress/lzw works reliably for GIF only. This is also the reason the TIFF package at golang.org/x/image/tiff provides its own lzw implementation for compression.

In addition with PDF there is a third variant of lzw needed.

pdfcpu supports lzw compression for PDF files and hosts a consolidated implementation of lzw at github.com/hhrutter/pdfcpu/lzw which works for GIF, PDF and TIFF. It not only supports the PDF LZWFilter but also processing PDFs with embedded TIFF images. Therefore it also provides a variant of golang.org/x/image/tiff already leveraging the new consolidated lzw implementation(github.com/hhrutter/pdfcpu/lzw).

This implementation provides

  • both lzw Reader and Writer as opposed to the original golang.org/x/image/tiff/lzw
  • support for CMYK color models.

Goal

A compress/lzw that works for a maximum number of components with a specific need for lzw support (as of now GIF, TIFF and PDF) and as a side effect of this an improved TIFF package that may or may not will make it into standard library one day.

Documentation

Overview

Package tiff is an enhanced version of x/image/tiff.

It uses a consolidated version of compress/lzw (https://github.com/hhrutter/pdfcpu/tree/master/lzw) for compression and also adds support for CMYK.

More information: https://github.com/hhrutter/pdfcpu/tree/master/tiff

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode

func Decode(r io.Reader) (img image.Image, err error)

Decode reads a TIFF image from r and returns it as an image.Image. The type of Image returned depends on the contents of the TIFF.

func DecodeConfig

func DecodeConfig(r io.Reader) (image.Config, error)

DecodeConfig returns the color model and dimensions of a TIFF image without decoding the entire image.

func Encode

func Encode(w io.Writer, m image.Image, opt *Options) error

Encode writes the image m to w. opt determines the options used for encoding, such as the compression type. If opt is nil, an uncompressed image is written.

Types

type CompressionType

type CompressionType int

CompressionType describes the type of compression used in Options.

const (
	Uncompressed CompressionType = iota
	Deflate
	LZW
	CCITTGroup3
	CCITTGroup4
)

Constants for supported compression types.

type FormatError

type FormatError string

A FormatError reports that the input is not a valid TIFF image.

func (FormatError) Error

func (e FormatError) Error() string

type Options

type Options struct {
	// Compression is the type of compression used.
	Compression CompressionType
	// Predictor determines whether a differencing predictor is used;
	// if true, instead of each pixel's color, the color difference to the
	// preceding one is saved.  This improves the compression for certain
	// types of images and compressors. For example, it works well for
	// photos with Deflate compression.
	Predictor bool
}

Options are the encoding parameters.

type UnsupportedError

type UnsupportedError string

An UnsupportedError reports that the input uses a valid but unimplemented feature.

func (UnsupportedError) Error

func (e UnsupportedError) Error() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL