Skip to content

Latest commit

 

History

History
61 lines (43 loc) · 691 Bytes

README.md

File metadata and controls

61 lines (43 loc) · 691 Bytes

imgx

JSON encoder and decoder for PNG images. Example can be found here.

Usage

Encoding

package main

import (
	"fmt"

	imgx "github.com/eminmuhammadi/imgx"
)

data := imgx.Data{}

file, err := imgx.Import("input.png")
if err != nil {
	panic(err)
}

data, err = imgx.Encode(file)
if err != nil {
	panic(err)
}

json, err := data.Json()
if err != nil {
	panic(err)
}

fmt.Println(json)

Decoding

package main

import (
    "fmt"

    imgx "github.com/eminmuhammadi/imgx"
)

data := imgx.Data{}
json := "{...}"

err := data.DecodeJson(json)
if err != nil {
	t.Error(err)
}

err = data.Save("output.png")
if err != nil {
	panic(err)
}