imgdiff

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2015 License: Apache-2.0, CC-BY-4.0 Imports: 5 Imported by: 1

README

imgdiff is an image comparison command line tool written in Go. It can compare two images using a simple binary (bitmap) and perceptual algorithms.

$ imgdiff -h
Compare two images and optionally output resulting diff image.
Supported image formats: png, jpeg, gif, tiff, bmp and webp.

Exit code will be non-zero if the difference is above specified threshold.
Threshold value can also be a percentage, e.g. 0.5%.

Currently supported comparison algorithms are 'binary' and 'perceptual'.
Binary algorithm simply compares the two images' pixels as is.

image1 and image2 can be either local file paths or URLs.

Output is usually a file path. Specify '-' to write to stdout instead.
Resulting image format is inferred from the output file extension
or -of argument otherwise. It defaults to png.

Usage: imgdiff [options] image1 image2
  -a="perceptual": diff algorithm
  -o="": diff output
  -of="": output image format
  -t=0: threshold value

Get the binary

Navigate to the releases page and download the executable compatible with your OS and ARCH: darwin/linux/windows and 386/amd64 respectively.

Compile

If you have Go installed, you can just do

go get github.com/crhym3/imgdiff/cmd/imgdiff

License

(c) Google, 2015. Licensed under an Apache-2 license.

Documentation

Overview

Package imgdiff provides image comparison using simple and perceptual diff algorithms.

Index

Constants

This section is empty.

Variables

View Source
var ErrSize = errors.New("images have different sizes")

ErrSize is used when the two images under comparison have different sizes.

Functions

This section is empty.

Types

type Differ

type Differ interface {
	// Compare compares images a and b, returning the resulting
	// difference image and the number of pixels that are different
	// according to an algorithm.
	//
	// It returns ErrSize if images have their width or height
	// do not match.
	Compare(a, b image.Image) (image.Image, int, error)
}

Differ is the image comparison interface. All supported algorithms implement it.

func NewBinary

func NewBinary() Differ

NewBinary creates a new Differ based on simple binary algorithm.

func NewDefaultPerceptual

func NewDefaultPerceptual() Differ

NewDefaultPerceptual returns the result of calling NewPerceptual with:

gamma = 2.2
luminance = 100.0
fov = 45.0
cf = 1.0
nocolor = false

func NewPerceptual

func NewPerceptual(gamma, luminance, fov, cf float64, nocolor bool) Differ

NewPerceptual creates a new Differ based on perceptual diff algorithm.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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