Skip to content

image.jpeg #

image.jpeg

JPEG decoding, configuration inspection, and encoding with a quality setting from 1 to 100. Importing this module registers JPEG with image.decode. Alpha is discarded during encoding. See image for examples and limits.

fn decode #

fn decode(reader io.Reader) !image.Image

decode reads a JPEG into an eight-bit, non-premultiplied NRGBA image.

fn decode_config #

fn decode_config(reader io.Reader) !image.Config

decode_config reads the color model and dimensions without decompressing pixels.

fn encode #

fn encode(mut writer io.Writer, img image.Image, options Options) !

encode writes img as a JPEG to writer; alpha is discarded.

fn encode_to_bytes #

fn encode_to_bytes(img image.Image, options Options) ![]u8

encode_to_bytes encodes img as a JPEG; alpha is discarded.

struct Options #

@[params]
struct Options {
pub:
	quality int = 75
}

Options selects JPEG encoding quality from 1 (smallest) to 100 (highest).