Git Product home page Git Product logo

goheif's Introduction

GoHeif - A go gettable decoder/converter for HEIC based on libde265

Install

  • heic2jpg to convert HEIC files to JPG preserving exif

go get github.com/jdeng/goheif/...

  • Tested

    • Mac OS X (High Sierra)
    • Linux (Ubuntu 16.04 / GCC 5.4)
    • Windows 7 64bit with TDM-GCC 32 (GCC 5.1) and golang 1.12 windows/386
  • Code Sample

func main() {
	flag.Parse()
	...
  
	fin, fout := flag.Arg(0), flag.Arg(1)
	fi, err := os.Open(fin)
	if err != nil {
		log.Fatal(err)
	}
	defer fi.Close()

	exif, err := goheif.ExtractExif(fi)
	if err != nil {
		log.Printf("Warning: no EXIF from %s: %v\n", fin, err)
	}

	img, err := goheif.DecodeImage(fi)
	if err != nil {
		log.Fatalf("Failed to parse %s: %v\n", fin, err)
	}

	fo, err := os.OpenFile(fout, os.O_RDWR|os.O_CREATE, 0644)
	if err != nil {
		log.Fatalf("Failed to create output file %s: %v\n", fout, err)
	}
	defer fo.Close()

	w, _ := newWriterExif(fo, exif)
	err = jpeg.Encode(w, img, nil)
	if err != nil {
		log.Fatalf("Failed to encode %s: %v\n", fout, err)
	}

	log.Printf("Convert %s to %s successfully\n", fin, fout)
}

What is done

  • Changes make to @bradfitz's (https://github.com/bradfitz) golang heif parser

    • Some minor bugfixes
    • A few new box parsers, noteably 'iref' and 'hvcC'
  • Include libde265's source code (SSE by default enabled) and a simple golang binding

  • A Utility heic2jpg to illustrate the usage.

License

  • heif and libde265 are in their own licenses

  • goheif.go, libde265 golang binding and the heic2jpg utility are in MIT license

Credits

TODO

  • Upstream the changes to heif?

goheif's People

Contributors

jdeng avatar mikegleasonjr avatar eleniums avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.