mita

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2025 License: MIT Imports: 9 Imported by: 0

README

Bots Community

Module for converting Image To Avif

Instalation

go get github.com/aejoy/mita

Usage

A simple example of converting PNG to AVIF:

package main

import (
	"os"
	"image"
	_ "image/png"
	_ "image/jpeg"
	"bytes"
	"github.com/aejoy/mita"
)

func main() {
	src, err := os.ReadFile(srcPath)
	if err != nil {
		panic(err)
	}

	img, _, err := image.Decode(bytes.NewReader(src))
	if err != nil {
		panic(err)
	}

	dst, err := os.Create(dstPath)
	if err != nil {
		panic(err)
	}
	defer dst.Close()

	if _, err := dst.Write(mita.Encode(img, Options{
		Quality: 75,
		Speed: 10,
	})); err != nil {
		panic(err)
	}
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode added in v0.2.0

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

func DecodeConfig added in v0.2.0

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

func Encode

func Encode(img image.Image, opts Options) []byte

Types

type ChromaType

type ChromaType int

type Options

type Options struct {
	MaxThreads         int
	AlphaPremultiplied int
	Depth              int
	Chroma             ChromaType
	Quality            int
	Speed              int
}

Jump to

Keyboard shortcuts

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