jpeg

package
v0.28.0 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2024 License: BSD-3-Clause Imports: 6 Imported by: 2

Documentation

Overview

Package jpeg implements a JPEG image decoder and encoder.

JPEG is defined in ITU-T T.81: https://www.w3.org/Graphics/JPEG/itu-t81.pdf.

Index

Constants

View Source
const DefaultQuality = 75

DefaultQuality is the default quality encoding parameter.

Variables

This section is empty.

Functions

func Decode

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

Decode reads a JPEG image from r. Different from the standard package, the decoded result will be received by the callback set by SetCallback().

func DecodeConfig

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

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

func Encode

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

Encode writes the Image m to w in JPEG 4:2:0 baseline format with the given options. Default parameters are used if a nil *Options is passed.

func SetCallback

func SetCallback(buf []uint16, fn Callback)

SetCallback registers the buffer and fn required for Callback. Callback can be called multiple times by calling Decode().

Types

type Callback

type Callback func(data []uint16, x, y, w, h, width, height int16)

A portion of the image data consisting of data, x, y, w, and h is passed to Callback. The size of the whole image is passed as width and height. If the callback is not called, add the implementation to image/png.readImagePass.

type FormatError

type FormatError string

A FormatError reports that the input is not a valid JPEG.

func (FormatError) Error

func (e FormatError) Error() string

type Options

type Options struct {
	Quality int
}

Options are the encoding parameters. Quality ranges from 1 to 100 inclusive, higher is better.

type Reader deprecated

type Reader interface {
	io.ByteReader
	io.Reader
}

Deprecated: Reader is not used by the image/jpeg package and should not be used by others. It is kept for compatibility.

type UnsupportedError

type UnsupportedError string

An UnsupportedError reports that the input uses a valid but unimplemented JPEG 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