heic

package module
v0.0.0-...-6b0e1fa Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2026 License: MIT Imports: 10 Imported by: 0

README

go-heic

実行に必要なファイル

このライブラリは purego を使って libheif の共有ライブラリを動的に読み込みます。事前に以下のファイルをインストールしてください。

OS 必要なファイル
Windows libheif.dll(または heif.dll
Linux libheif.so
macOS libheif.dylib

使い方

インポート
import "github.com/f0reth/go-heic"
デコード(HEIC → image.Image)
f, _ := os.Open("input.heic")
defer f.Close()

img, err := heic.Decode(f)
設定のみのデコード(サイズや色モデルの取得)
f, _ := os.Open("input.heic")
defer f.Close()

cfg, err := heic.DecodeConfig(f)
// cfg.Width, cfg.Height, cfg.ColorModel
image パッケージ経由のデコード

import _ "github.com/f0reth/go-heic" のように副作用インポートすると、 image.Decode / image.DecodeConfig で HEIC を自動判別してデコードできます。

img, format, err := image.Decode(f) // format == "heic"
ライブラリの読み込み確認
if err := heic.Dynamic(); err != nil {
    log.Fatal("共有ライブラリが見つかりません:", err)
}

Documentation

Overview

Package heic implements an HEIC image decoder based on the libheif/libde265 shared library used via purego (CGo-free).

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMemRead  = errors.New("heic: mem read failed")
	ErrMemWrite = errors.New("heic: mem write failed")
	ErrDecode   = errors.New("heic: decode failed")
)

Errors .

Functions

func Decode

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

Decode reads a HEIC image from r and returns it as an image.Image.

func DecodeConfig

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

DecodeConfig returns the color model and dimensions of a HEIC image without decoding the entire image.

func Dynamic

func Dynamic() error

Dynamic returns error (if there was any) during opening dynamic/shared library.

func Init

func Init()

Init is kept for backward compatibility and does nothing. The dynamic/shared library is loaded during package initialization; use Dynamic to check whether loading succeeded.

Types

This section is empty.

Jump to

Keyboard shortcuts

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