mita

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2025 License: MIT Imports: 5 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 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
JackTT - Gopher 🇻🇳