img

command module
v0.0.0-...-6905684 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2019 License: MIT Imports: 9 Imported by: 0

README

img docs

A collection of image manipulation tools. Each tool takes an input file from standard input, this needs to be in PNG, JPEG or GIF format. They output the resulting image (by default in PNG format) to standard output.

To install run,

$ go install github.com/Nyarum/img

You can then run go help and go help [command] for information.

The aim of img is not to be fast, if you want fast use GraphicsMagick, the aim is to be readable. Diving through endless files of C and C++ to find out how a certain effect is implemented is no fun, reading a single Go file is hopefully better.

Example (Command Line)

Here is an example: First we convert the image to greyscale using the values from the red colour channel, then boost the contrast slightly using a linear function, and finally tint the image with a dark red.

(img greyscale --red | \
  img contrast --linear --ratio 1.5 | \
  img tint --with '#83121344') < input.png > output.png

You can see here how easy it is to chain different tools together using pipes.

Example (Go)

You can also use the img libraries in Go code. We could rewrite the previous example as,

// example.go
package main

import (
  "github.com/Nyarum/img/contrast"
  "github.com/Nyarum/img/greyscale"
  "github.com/Nyarum/img/tint"

  "image/png"
  "os"
)

func main() {
  input, _ := os.Open(os.Args[1])
  img,   _ := png.Decode(input)

  img = greyscale.Red(img)
  img = contrast.Linear(img, 1.5)
  img = tint.Tint(img, color.NRGBA{131, 18, 19, 255})

  output, _ := os.Create(os.Args[2])
  png.Encode(output, img)
}

This can then be compiled and run like ./example input.png output.png.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
Package altcolor includes useful color models absent in the standard library's "image/color" package.
Package altcolor includes useful color models absent in the standard library's "image/color" package.
Package blend implements various blending mode functions between two images.
Package blend implements various blending mode functions between two images.
Package blur provides functions for blurring images.
Package blur provides functions for blurring images.
Package channel provides functions to alter the values of separate color channels in an image.
Package channel provides functions to alter the values of separate color channels in an image.
Package contrast implements functions to adjust the contrast of an image.
Package contrast implements functions to adjust the contrast of an image.
Package crop provides functions for cropping an image to a smaller size.
Package crop provides functions for cropping an image to a smaller size.
Package exif provides a go interface for exiftool.
Package exif provides a go interface for exiftool.
Package gamma implements functions to adjust the gamma of an image.
Package gamma implements functions to adjust the gamma of an image.
Package greyscale implements various functions to convert an image to greyscale.
Package greyscale implements various functions to convert an image to greyscale.
Package levels provides functions to alter the distibution of values of a color channel in an image.
Package levels provides functions to alter the distibution of values of a color channel in an image.
Package pixelate implements various functions for pixelating images.
Package pixelate implements various functions for pixelating images.
Package sharpen provides functions to sharpen an image.
Package sharpen provides functions to sharpen an image.
Package shuffle implements functions to randomly swap pixels in an image.
Package shuffle implements functions to randomly swap pixels in an image.
Package tint implements a single function to tint an image with a specified colour.
Package tint implements a single function to tint an image with a specified colour.
Package utils provides useful helper functions for working with Images and Colors.
Package utils provides useful helper functions for working with Images and Colors.
Package vibrance provides functions to adjust the "vibrancy" of images.
Package vibrance provides functions to adjust the "vibrancy" of images.

Jump to

Keyboard shortcuts

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