jpegli

package module
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2024 License: BSD-3-Clause Imports: 16 Imported by: 4

README

Documentation

Overview

Package jpegli implements an JPEG image encoder/decoder based on jpegli compiled to WASM.

Index

Constants

View Source
const DefaultDCTMethod = DCTISlow

DefaultDCTMethod is the default DCT algorithm method.

View Source
const DefaultQuality = 75

DefaultQuality is the default quality encoding parameter.

Variables

View Source
var (
	ErrMemRead  = errors.New("jpegli: mem read failed")
	ErrMemWrite = errors.New("jpegli: mem write failed")
	ErrDecode   = errors.New("jpegli: decode failed")
	ErrEncode   = errors.New("jpegli: encode failed")
)

Errors .

Functions

func Decode

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

Decode reads a JPEG image from r and returns it as an image.Image.

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 DecodeWithOptions

func DecodeWithOptions(r io.Reader, o *DecodingOptions) (image.Image, error)

DecodeWithOptions reads a JPEG image from r with decoding options.

func Encode

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

Encode writes the image m to w with the given options.

func Init added in v0.3.0

func Init()

Init initializes wazero runtime and compiles the module. There is no need to explicitly call this function, first Decode/Encode will initialize the runtime.

Types

type DCTMethod

type DCTMethod int

DCTMethod is the DCT/IDCT method type.

const (
	// DCTISlow is slow but accurate integer algorithm
	DCTISlow DCTMethod = iota
	// DCTIFast is faster, less accurate integer method
	DCTIFast
	// DCTFloat is floating-point: accurate, fast on fast HW
	DCTFloat
)

type DecodingOptions

type DecodingOptions struct {
	// ScaleTarget is the target size to scale image.
	ScaleTarget image.Rectangle
	// Fancy upsampling.
	FancyUpsampling bool
	// Block smoothing.
	BlockSmoothing bool
	// Use arithmetic coding instead of Huffman.
	ArithCode bool
	// DCTMethod is DCT Algorithm method.
	DCTMethod DCTMethod
}

DecodingOptions are the decoding parameters.

type EncodingOptions

type EncodingOptions struct {
	// Quality in the range [0,100]. Default is 75.
	Quality int
	// Chroma subsampling setting, 444|440|422|420.
	ChromaSubsampling image.YCbCrSubsampleRatio
	// Progressive level in the range [0,2], where level 0 is sequential, and greater level value means more progression steps.
	ProgressiveLevel int
	// Huffman code optimization.
	// Enabled by default.
	OptimizeCoding bool
	// Uses adaptive quantization for creating more zero coefficients.
	// Enabled by default.
	AdaptiveQuantization bool
	// Use standard quantization tables from Annex K of the JPEG standard.
	// By default, jpegli uses a different set of quantization tables and different scaling parameters for DC and AC coefficients.
	StandardQuantTables bool
	// Apply fancy downsampling.
	FancyDownsampling bool
	// DCTMethod is the DCT algorithm method.
	DCTMethod DCTMethod
}

EncodingOptions are the encoding parameters.

Jump to

Keyboard shortcuts

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