exiflign

package module
v0.0.0-...-8b95e9a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 14, 2018 License: MIT Imports: 5 Imported by: 0

README

GoDoc

exiflign

This package exposes an interface for "normalizing" JPEG images that have their orientation EXIF encoded. This library was designed for working with images uploaded from phone cameras that usually have their orientation tagged, which results in rotated/mirrored images when using the Go image/jpeg library. Supports little-endian and big-endian EXIF encodings, as well as all possible tag transformations.

Example

This package is very easy to use, but exposes lower-level functions for more control. A very basic use example:

fIn, err := os.Open("./input.jpg")
if err != nil { return err }
defer fIn.Close()

fOut, err := os.Create("./output.jpg")
if err != nil { return err }
defer fOut.Close()

err = exiflign.Normalize(fIn, fOut)
if err != nil { return err }

More control, as well as in-memory transformations, can also be performed.

Documentation

The full documentation of this package can be found on GoDoc.

Documentation

Overview

This package exposes an interface for "normalizing" JPEG images that have their orientation EXIF encoded. This library was designed for working with images uploaded from phone cameras that usually have their orientation tagged, which results in a rotated/mirrored images when using the Go image/jpeg library. Supports little-endian and big-endian EXIF encodings, as well as all possible tag transformations.

Index

Constants

This section is empty.

Variables

View Source
var NoExifError error = errors.New("The given file does not contain any EXIF orientation information.")

Functions

func GetOrientationTag

func GetOrientationTag(r io.ReadSeeker) (uint16, error)

GetOrientationTag produces a value between 1 and 8, inclusive, for a given JPEG image in r. This value describes the transformations required to produce the correct image. The excellent article by Magnus Hoff covers this in more detail:

https://magnushoff.com/jpeg-orientation.html

func Normalize

func Normalize(r io.ReadSeeker, w io.Writer) error

Normalize is the "quick-fix" function of this package. It requires an io.ReadSeeker since it needs to detect the orientation and then decode the image. It will write the orientation-corrected image to w. If the JPEG image in r does not have EXIF data or does not have orientation data, r is simply copied to w. When finished, the internal position in r will be at io.SeekStart.

func TransformForTag

func TransformForTag(img image.Image, tag uint16) image.Image

TransformForTag performs the neccessary transformation on img that will facilitate removal of the orientation tag.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL