andviro / go-libtiff

Simple libtiff to go binding

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Go-libtiff

A thin Golang wrapper around libtiff. Allows loading and extracting multipage tiffs.

package main

import (
	"fmt"
    "github.com/andviro/go-libtiff/libtiff"
	"image/png"
	"os"
)

func main() {
	tiff, err := libtiff.Open("test.tiff")
	if err != nil {
		panic(err)
	}
	defer tiff.Close()

	n := tiff.Iter(func(n int) {
		img, err := tiff.GetRGBA()
		if err != nil {
			panic(err)
		}

        w, _ := os.Create(fmt.Sprintf("page%d.png", n+1))
		png.Encode(w, &img)
	})
	fmt.Printf("Total pages: %d\n", n)
}

About

Simple libtiff to go binding


Languages

Language:Go 100.0%