99designs / colorific

Automatic color palette detection
ISC License
700 stars 55 forks source link

Output detected palette as image #2

Closed pbaehr closed 12 years ago

pbaehr commented 12 years ago

I've added a function which outputs the palette as a PNG file, similar to the swatches at the bottom of your example and labels each color with its hexidecimal value. This option is toggled by a -o (for "output") flag on the command line.

I also changed it to accept filenames as parameters as well as streamed input which (in my opinion) makes it simpler to run for single files and small batches.

Not sure if this is in the scope of the project, but I thought it was nice to get more visual feedback out of the program.

dhotson commented 12 years ago

Thank you very much for the contribution! :--)

I really like the output mode—it's something that has been bothering us in terms of being able to quickly see if results are better. This works perfectly. The only thing I'd add is a description to the -o option for --help to help new users out.

The filename arguments feature is great too. I'd like to keep the streaming functionality working as well if possible since we use it to process millions of images. It'd be great to support both.

pbaehr commented 12 years ago

Help for the -o flag is in.

I don't think the argument mode interferes with the streaming mode, but to be honest the reason I had added it was I had trouble getting the streaming mode to work on my Windows computer so I haven't fully tested it yet.

If no arguments are entered on the command line it enters streaming mode.

dhotson commented 12 years ago

Ah awesome, thanks so much. :-)

I tested your changes quickly on linux and the streaming stuff didn't quite work. I got this error:

logo3w.png extract_colors() got an unexpected keyword argument 'save_palette'
pbaehr commented 12 years ago

I think my last commit should take care of that error. I apologize for not being sure, but my personal computer bit the dust some time ago and my work computers all run Windows, so I don't have a Linux computer to test on.

When I pass a filename as a stream in Windows I get a totally different error (Bad file descriptor) so until I figure that out I'm guessing. Not sure if I'm doing something wrong or if Windows doesn't support this method.

dhotson commented 12 years ago

Sorry about the wait. I just tested this out and everything works as promised. Thanks again.

pbaehr commented 12 years ago

Cool. I'm working on another function to output colors as an Adobe ASE file. I'll let you know if anything comes of it.

dhotson commented 12 years ago

Hey neat, I didn't know there was a file format for color palettes. Good to know.