jpeg

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2024 License: BSD-3-Clause Imports: 12 Imported by: 0

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.

func DecodeConfig

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

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

func DecodeExtended

func DecodeExtended(ctx context.Context, r io.Reader, opts ...image.ReadOption) (image.Image, image.Metadata, error)

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 EncodeExtended

func EncodeExtended(ctx context.Context, w io.Writer, m image.Image, opts ...image.WriteOption) error

EncodeExtended writes the image m to w in JPEG 4:2:0 baseline format with the given options. Default parameters are used in no options are passed.

Types

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 Metadata

type Metadata struct {

	// Width holds the image width, in pixels
	Width int
	// Height holds the image height, in pixels
	Height int
	// ColorModel holds the image color model
	ColorModel color.Model

	// The version of this JPEG file
	Version Version
	// Units holds the units for the ppX calculations
	Units Units
	// XDensity holds the pixels-per-unit for the X axis
	XDensity uint16
	// YDensity holds the pixels-per
	YDensity uint16

	// Thumbnail is the thumbnail image in the APP9 JFIF segment.
	Thumbnail image.Image
	// XThumbnail is the x dimension of the thumbnail image
	XThumbnail uint8
	// YThumbnail is the y dimension of the thumbnail image
	YThumbnail uint8
	// contains filtered or unexported fields
}

func (*Metadata) EXIF

func (m *Metadata) EXIF(ctx context.Context, opt ...image.ReadOption) (*metadata.EXIF, error)

Exif returns the decoded exif metadata for an image. If there is no exif metadata then it will return nil. The returned exif structure is still associated with its parent metadata object, and changes to it will be persistent.

Note that the exif information may be decoded lazily.

func (*Metadata) GetConfig

func (m *Metadata) GetConfig() image.Config

func (*Metadata) ICC

func (m *Metadata) ICC(ctx context.Context, opt ...image.ReadOption) (*metadata.ICC, error)

func (*Metadata) ImageMetadataFormat

func (m *Metadata) ImageMetadataFormat() string

func (*Metadata) IsImageWriteOption

func (m *Metadata) IsImageWriteOption()

IsImageWriteOption lets a jpeg metadata struct be passed as a write option to EncodeExtended.

func (*Metadata) SetEXIF

func (m *Metadata) SetEXIF(e *metadata.EXIF)

SetExif replaces the exif information associated with the metdata object.

func (*Metadata) SetIcc

func (m *Metadata) SetIcc(i *metadata.ICC)

func (*Metadata) SetXMP

func (m *Metadata) SetXMP(x *metadata.XMP)

SetXmp replaces the XMP information associated with the metadata object.

func (*Metadata) XMP

func (m *Metadata) XMP(ctx context.Context, opt ...image.ReadOption) (*metadata.XMP, error)

Xmp returns the xmp information associated with the metadata object. If there is no xmp information then it will return nil. The returned xmp structure will still be associated with its parent metadata object, and changes to it will be persistent.

Note that the xmp information may be decoded lazily.

type Options

type Options struct {
	Quality int
}

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

func (Options) IsImageWriteOption

func (_ Options) IsImageWriteOption()

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 Units

type Units uint8

func (Units) String

func (u Units) String() string

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

type Version

type Version uint16

func (Version) String

func (v Version) String() string

Jump to

Keyboard shortcuts

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