okaneco / kmeans-colors

k-means clustering library and binary to find dominant colors in images
Apache License 2.0
139 stars 9 forks source link

Hex Colors starting with '0' are not parsed #33

Closed DerLando closed 4 years ago

DerLando commented 4 years ago

Hi @okaneco,

first of all: I love the library and cli, really having some fun playing around with it right now, thanks a lot for putting this together!

I found one issue with regards to parsing hex numbers which start with a leading 0 (Zero). The leading 0 seems to be cut off when parsed as an input given via the '-c' flag. f.e. '035951' becomes '35951' when parsed as seen in the following screenshot:

image

The Pallette I generated the colors with is this: pallette_1

okaneco commented 4 years ago

Thanks! Those are nice colors.

You might have to enclose the colors with quotes. I've written other scripts which required single quotes around the arguments for parsing. It might have been the parsing logic I wrote or how structopt/clap handled the arguments.

I used the colors as written and didn't encounter an error: kmeans_colors.exe find -i baboon-resize.jpg -c 035951,037368,058abf,f25116,a7c8f2 -o github.png

Perhaps try -c '035951,037368,058abf,f25116,a7c8f2'. I assume this might be a terminal/operating system issue. What OS and term are you using? I'm using cygwin and git-bash on Windows mainly now, but I've used this tool on OS X as well.

github

DerLando commented 4 years ago

Thanks for getting back to me so quick :)

Enclosing the colors in single quotes did the trick!

For the record, I am using Windows 10 64 Bit and Powershell as a terminal

profile_c_small

okaneco commented 4 years ago

Glad to hear that and thanks for the information, I'm not too familiar with Powershell.

I put a note in the readme for this issue in case anyone else runs into it in the future, and I'll include a similar note in future crates I publish with similar arg parsing.