icns

package module
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

README

github.com/kroksys/icns

This repository contains a library to handle the Apple Icon Image format, as described here: https://en.wikipedia.org/wiki/Apple_Icon_Image_format

License

Apache 2.0; see LICENSE for details.

Disclaimer

This project is not an official Google project. It is not supported by Google and Google specifically disclaims all warranties as to its quality, merchantability, or fitness for a particular purpose.

Documentation

Overview

Package icns provides read/write operations for the Apple ICNS file format. It currently only supports a subset of the specification, covering JPEG and PNG data types.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Encode

func Encode(w io.Writer, i *ICNS) error

Encode writes a .icns file to the provided writer.

Types

type Compatibility

type Compatibility uint

Compatibility represents compatibility with an OS version.

const (
	// Allegro is 8.5
	Allegro Compatibility = iota
	// Cheetah is 10.0
	Cheetah
	// Leopard is 10.5
	Leopard
	// Lion is 10.7
	Lion
	// MountainLion is 10.8
	MountainLion
	// Newest version
	Newest = MountainLion
	// Oldest version
	Oldest Compatibility = Allegro
)

type Format added in v0.0.2

type Format struct {
	Code        uint32
	CombineCode uint32
	Res         Resolution
	Compat      Compatibility
	Codec       codec.Codec
}

type ICNS

type ICNS struct {
	Assets []*Img
	// contains filtered or unexported fields
}

ICNS encapsulates the Apple Icon Image format specification.

func Decode

func Decode(r io.Reader) (*ICNS, error)

Decode loads a .icns file from the provided reader.

func NewICNS

func NewICNS(opts ...Option) *ICNS

NewICNS creates a new icon based on provided options.

func (*ICNS) Add

func (i *ICNS) Add(im image.Image) error

Add adds new image to the icon, assuming its resolution is acceptable. This also replaces previous images at that resolution.

func (*ICNS) ByResolution

func (i *ICNS) ByResolution(r Resolution) (image.Image, error)

ByResolution extracts an image from the icon, at the provided resolution.

func (*ICNS) ClosestResolution added in v0.0.3

func (i *ICNS) ClosestResolution(r Resolution) (*Img, error)

Finds and returns image that is closest to requested resolution.

func (*ICNS) HighestResolution

func (i *ICNS) HighestResolution() (image.Image, error)

HighestResolution extracts the image from the icon that has the highest resolution.

func (*ICNS) Info

func (i *ICNS) Info() string

Info provides information about the ICNS

type Img

type Img struct {
	image.Image
	Format  *Format
	Encoder string
	Data    []byte
}

type Option

type Option func(*ICNS)

Option is the type for ICNS creation options.

func WithMaxCompatibility

func WithMaxCompatibility(c Compatibility) Option

WithMaxCompatibility sets the maximum expected compatibility (defaults to Newest).

func WithMinCompatibility

func WithMinCompatibility(c Compatibility) Option

WithMinCompatibility sets the minimum expected compatibility (defaults to Oldest).

type Resolution

type Resolution = codec.Resolution

Resolution represents the supported resolutions in pixels.

const (
	Pixel16   Resolution = 16
	Pixel32   Resolution = 32
	Pixel48   Resolution = 48
	Pixel64   Resolution = 64
	Pixel128  Resolution = 128
	Pixel256  Resolution = 256
	Pixel512  Resolution = 512
	Pixel1024 Resolution = 1024
)

All supported resolutions

Directories

Path Synopsis
internal
rle
Package rle implements a simple RLE encoder, as used in ICNS format.
Package rle implements a simple RLE encoder, as used in ICNS format.

Jump to

Keyboard shortcuts

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