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: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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
⌂ 换网址