Skip to content

jkawamoto/go-pngtext

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-pngtext

Go library GoDoc

Parse textual data from a PNG file.

Usage

This code opens a file image.png and prints all textual data stored in the file:

package main

import (
	"fmt"
	"log"
	"os"

	"github.com/jkawamoto/go-pngtext"
)

func main() {
	r, err := os.Open("image.png")
	if err != nil {
		log.Fatalf("failed to open a file: %v", err)
	}
	defer func() {
		if err := r.Close(); err != nil {
			log.Fatalf("failed to close a file: %v", err)
		}
	}()

	res, err := pngtext.ParseTextualData(r)
	if err != nil {
		log.Fatalf("failed to parse textual data: %v", err)
	}

	for _, v:= range res{
        fmt.Printf("%v: %v\n", v.Keyword, v.Text)	
    }
}

License

This software is released under the MIT License, see LICENSE.