
Product
Introducing Socket Firewall Enterprise: Flexible, Configurable Protection for Modern Package Ecosystems
Socket Firewall Enterprise is now available with flexible deployment, configurable policies, and expanded language support.
github.com/cenkalti/dominantcolor
Advanced tools
Find dominant color in images
import "github.com/cenkalti/dominantcolor"
Package dominantcolor provides a function for finding a color that represents the calculated dominant color in the image. This uses a KMean clustering algorithm to find clusters of pixel colors in RGB space.
The algorithm is ported from Chromium source code:
See more at: http://godoc.org/github.com/cenkalti/dominantcolor
package main
import (
"fmt"
"github.com/cenkalti/dominantcolor"
"image"
_ "image/jpeg"
_ "image/png"
"os"
)
func FindDomiantColor(fileInput string) (string, error) {
f, err := os.Open(fileInput)
defer f.Close()
if err != nil {
fmt.Println("File not found:", fileInput)
return "", err
}
img, _, err := image.Decode(f)
if err != nil {
return "", err
}
return dominantcolor.Hex(dominantcolor.Find(img)), nil
}
func main() {
fmt.Println(FindDomiantColor("aa.png"))
}
#CA5527
Thanks to @stuartmscott for creating a GUI: https://github.com/stuartmscott/dominantcolor
FAQs
Unknown package
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket Firewall Enterprise is now available with flexible deployment, configurable policies, and expanded language support.

Security News
Open source dashboard CNAPulse tracks CVE Numbering Authorities’ publishing activity, highlighting trends and transparency across the CVE ecosystem.

Product
Detect malware, unsafe data flows, and license issues in GitHub Actions with Socket’s new workflow scanning support.