deanimator

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2022 License: MIT Imports: 5 Imported by: 1

README

Deanimator

Deanimator is a Go package that can detect animated images and "deanimate" them by rendering just the first frame as a static image.

Busy Slack:

Becomes Calm Slack:

Installation

Add the module via go mod:

go get <TODO: module name here!>

Usage

When using the module, make sure to import / register the deanimation libraries you want to support (similar to the image package in the standard library). For example:

import (
    _ "<package>/png"
    _ "<package>/gif"
    _ "<package>/webp"
)

TODO: link to go pkg docs when published

Documentation

Overview

Package deanimator provides a common interface for detecting animation and deanimation of image data streams. Multiple image formats are supported and additional formats can be registered by consumers.

Index

Constants

This section is empty.

Variables

View Source
var ErrFormat = errors.New("deanimator: unknown format")

ErrFormat indicates that decoding encountered an unknown format.

Functions

func IsAnimated

func IsAnimated(r io.Reader) (bool, string, error)

IsAnimated returns whether the image data in the reader is a known format and is recognized as having multiple animation frames. If a format is not matched, ErrFormat is returned, otherwise a flag indicating whether it is animated and the format name are returned. This function only consumes as much of the reader as is necessary to determine if something is animated.

func RegisterFormat

func RegisterFormat(name, magic string, isAnimated func(io.Reader) (bool, error), renderFirstFrame func(io.Reader, io.Writer) error)

RegisterFormat allows consumers to create their own deanimation format support,the format registration/handling code for deanimator closely follows that of the image package in the std library. To create your own format handling, you can read more about its magic string matching to determing the best way to structure your registration.

func RenderFirstFrame

func RenderFirstFrame(r io.Reader, w io.Writer) (string, error)

RenderFirstFrame renders the first frame of an animated image to the provided writer. It will read as much of the reader as is necessary to do so. It will also return the matching format. If no format matched, it will return ErrFormat.

Some implementations of RenderFirstFrame may change the encoding format of the first frame (for example from GIF to PNG).

Types

This section is empty.

Directories

Path Synopsis
cmd
gif
Package gif provides animated GIF image format support for deanimator.
Package gif provides animated GIF image format support for deanimator.
parser
A modified version of golang 1.18's image/gif/reader.go Only reads the first frame of a gif Also includes patch from https://go-review.googlesource.com/c/go/+/329329
A modified version of golang 1.18's image/gif/reader.go Only reads the first frame of a gif Also includes patch from https://go-review.googlesource.com/c/go/+/329329
Package png provides animated PNG image format support for deanimator.
Package png provides animated PNG image format support for deanimator.
Package webp provides animated WEBP image format support for deanimator.
Package webp provides animated WEBP image format support for deanimator.
Package window provides a windowed reader implementation used by some of the image format packages.
Package window provides a windowed reader implementation used by some of the image format packages.

Jump to

Keyboard shortcuts

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