bruston / palette

HTTP API returning the RGB values used in an image.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

palette

Tiny HTTP API returning the RGB values used in an image.

Works with GIF, JPEG and PNG.

Usage

Usage of ./pal:
  -listen string
    	host:port to use (default ":8080")
  -max_size int
    	maximum size of image to process in bytes (default 1000000)
  -r_timeout duration
    	read timeout in seconds (default 1m0s)
  -w_timeout duration
    	write timeout in seconds (default 1m0s)

The API

Return all colours used in an image:

curl --data-binary "@/path/to/image.png" "localhost:8080/"

Filter out colours that take up less than n pixels:

curl --data-binary "@/path/to/image.png" "localhost:8080/?min=100"

Output:

[{"red":150,"green":206,"blue":180},{"red":255,"green":238,"blue":173},{"red":255,"green":111,"blue":105},{"red":255,"green":204,"blue":92},{"red":136,"green":216,"blue":176}]

Pretty print output:

curl --data-binary "@/path/to/image.png" "localhost:8080/?pretty=true"

Output:

[
	{
		"red": 136,
		"green": 216,
		"blue": 176
	},
	{
		"red": 150,
		"green": 206,
		"blue": 180
	},
	{
		"red": 255,
		"green": 238,
		"blue": 173
	},
	{
		"red": 255,
		"green": 111,
		"blue": 105
	},
	{
		"red": 255,
		"green": 204,
		"blue": 92
	}
]

About

HTTP API returning the RGB values used in an image.

License:MIT License


Languages

Language:Go 100.0%