Skip to content

A Go library for cropping images by removing borders with specified color.

License

Notifications You must be signed in to change notification settings

nxshock/colorcrop

Repository files navigation

colorcrop

Build Status Coverage Status Go Report Card Status GoDoc

A pure Go library for cropping images by removing borders with specified color.

Installation

go get -u github.com/nxshock/colorcrop

Usage

Import package with:

import "github.com/nxshock/colorcrop"

Crop white borders with 50% of thresold:

croppedImage := colorcrop.Crop(
    sourceImage,                    // for source image
    color.RGBA{255, 255, 255, 255}, // crop white border
    0.5)                            // with 50% thresold

You may use custom comparator of colors:

croppedImage := colorcrop.CropWithComparator(
    sourceImage,                    // for source image
    color.RGBA{255, 255, 255, 255}, // crop white border
    0.5,                            // with 50% thresold
    colorcrop.CmpCIE76)             // using CIE76 standart for defining color difference

List of available comparators:

Comparator Description
CmpRGBComponents simple RGB components difference: abs(r1-r2)+abs(g1-g2)+abs(b1-b2) (default);
CmpEuclidean Euclidean difference;
CmpCIE76 difference of two colors defined in CIE76 standard.

Examples

See here.

About

A Go library for cropping images by removing borders with specified color.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages