Coder Social home page Coder Social logo

tj3's Introduction

Go JPEG Encode and Decode via TurboJPEG v3

Simple JPEG Encoder and Decoder. Can often be used instead of Go's JPEG encoder and decoder:

 import (
-    "image/jpeg"
+    jpeg "github.com/fzwoch/tj3"
 )

or, if you only want the transparent decoding feature:

 import (
     "image"
-    _ "image/jpeg"
+    _ "github.com/fzwoch/tj3"
 )

Cgo

At build time of your application you will need to tell the Go compiler where to find the TurboJPEG header and library files. Check Go's cgo documentation for more details.

export CGO_CFLAGS="-I/path/to/libjpeg-turbo/header-files"
export CGO_LDFLAGS="-L/path/to/libjpeg-turbo/library"

For example, if your system has pkg-config, here is how to run tests:

CGO_CFLAGS=`pkg-config --cflags libturbojpeg` \
CGO_LDFLAGS=`pkg-config --libs libturbojpeg` \
go test -v

Benchmark

cpu: AMD Ryzen 7 5700X 8-Core Processor
BenchmarkDecodeYUV420_TurboJPEG-16    	    9301	    148467 ns/op
BenchmarkDecodeYUV420_GoJPEG-16       	    1293	    818696 ns/op
BenchmarkEncodeYUV420_TurboJPEG-16    	    7362	    155416 ns/op
BenchmarkEncodeYUV420_GoJPEG-16       	    1129	    972425 ns/op

tj3's People

Contributors

fzwoch avatar

Stargazers

 avatar

Watchers

 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.