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
- func Decode(r io.Reader) (image.Image, error)
- func DecodeConfig(r io.Reader) (image.Config, error)
- func DecodeExtended(ctx context.Context, r io.Reader, opts ...image.ReadOption) (image.Image, image.Metadata, error)
- func Encode(w io.Writer, m image.Image, o *Options) error
- func EncodeExtended(ctx context.Context, w io.Writer, m image.Image, opts ...image.WriteOption) error
- type FormatError
- type Metadata
- func (m *Metadata) EXIF(ctx context.Context, opt ...image.ReadOption) (*metadata.EXIF, error)
- func (m *Metadata) GetConfig() image.Config
- func (m *Metadata) ICC(ctx context.Context, opt ...image.ReadOption) (*metadata.ICC, error)
- func (m *Metadata) ImageMetadataFormat() string
- func (m *Metadata) IsImageWriteOption()
- func (m *Metadata) SetEXIF(e *metadata.EXIF)
- func (m *Metadata) SetIcc(i *metadata.ICC)
- func (m *Metadata) SetXMP(x *metadata.XMP)
- func (m *Metadata) XMP(ctx context.Context, opt ...image.ReadOption) (*metadata.XMP, error)
- type Options
- type Readerdeprecated
- type Units
- type UnsupportedError
- type Version
Constants ¶
const DefaultQuality = 75
DefaultQuality is the default quality encoding parameter.
Variables ¶
This section is empty.
Functions ¶
func DecodeConfig ¶
DecodeConfig returns the global color model and dimensions of a JPEG image without decoding the entire image.
func DecodeExtended ¶
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 ¶
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) ImageMetadataFormat ¶
func (*Metadata) IsImageWriteOption ¶
func (m *Metadata) IsImageWriteOption()
IsImageWriteOption lets a jpeg metadata struct be passed as a write option to EncodeExtended.
func (*Metadata) SetEXIF ¶
SetExif replaces the exif information associated with the metdata object.
func (*Metadata) XMP ¶
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 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