convert

package module
v0.0.0-...-af941ea Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2026 License: MIT Imports: 11 Imported by: 0

README

imgutils-convert

Format conversion (PNG, JPEG, WebP, etc.)

Documentation

Overview

Package convert provides image format conversion utilities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Convert

func Convert(r io.Reader, w io.Writer, format Format, opts Options) error

Convert reads an image and converts it to a different format.

func ConvertFile

func ConvertFile(inputPath, outputPath string, opts Options) error

ConvertFile converts an image file to a different format.

func Encode

func Encode(w io.Writer, img image.Image, format Format, opts Options) error

Encode writes an image to the writer in the specified format.

func ToBMP

func ToBMP(img image.Image, w io.Writer) error

ToBMP converts an image to BMP format.

func ToGIF

func ToGIF(img image.Image, w io.Writer) error

ToGIF converts an image to GIF format.

func ToJPEG

func ToJPEG(img image.Image, w io.Writer, quality int) error

ToJPEG converts an image to JPEG format.

func ToPNG

func ToPNG(img image.Image, w io.Writer) error

ToPNG converts an image to PNG format.

func ToTIFF

func ToTIFF(img image.Image, w io.Writer) error

ToTIFF converts an image to TIFF format.

Types

type Format

type Format string

Format represents an image format.

const (
	JPEG Format = "jpeg"
	PNG  Format = "png"
	GIF  Format = "gif"
	BMP  Format = "bmp"
	TIFF Format = "tiff"
)

func Decode

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

Decode reads an image from the reader.

func FormatFromExtension

func FormatFromExtension(path string) Format

FormatFromExtension determines the format from a file extension.

type Options

type Options struct {
	Quality int // JPEG quality (1-100), default 85
}

Options configures the conversion.

func DefaultOptions

func DefaultOptions() Options

DefaultOptions returns sensible defaults.

Jump to

Keyboard shortcuts

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