color_extractor

package module
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2023 License: MIT Imports: 4 Imported by: 10

README

Simple image color extractor written in Go with no external dependencies.

Go Reference Go Report Card Go Coverage

Demo:

https://color-extractor-demo.marekm4.com/

Blog post:

https://medium.com/@marek.michalik/c-vs-rust-vs-go-performance-analysis-945ab749056c

Usage:

package main

import (
	"fmt"
	"image"
	_ "image/jpeg"
	"os"

	"github.com/marekm4/color-extractor"
)

func main() {
	file := "Fotolia_45549559_320_480.jpg"
	imageFile, _ := os.Open(file)
	defer imageFile.Close()

	image, _, _ := image.Decode(imageFile)
	colors := color_extractor.ExtractColors(image)

	fmt.Println(colors)
}

Example image:

Image

Extracted colors:

Colors

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractColors

func ExtractColors(image image.Image) []color.Color

func ExtractColorsWithConfig

func ExtractColorsWithConfig(image image.Image, config Config) []color.Color

Types

type ByCount

type ByCount []bucket

func (ByCount) Len

func (c ByCount) Len() int

func (ByCount) Less

func (c ByCount) Less(i, j int) bool

func (ByCount) Swap

func (c ByCount) Swap(i, j int)

type Config

type Config struct {
	DownSizeTo  float64
	SmallBucket float64
}

Jump to

Keyboard shortcuts

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