Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I do love that feature. I developed something like this a couple years ago for a back office part of a project:

https://www.dropbox.com/sh/4p5m4719ehvpohc/GUEHcYecYv

I don't have a good example of the project any longer, but I took a few snapshots during the development process. My test page allowed you to upload a logo and have the page dynamically change to match the new logo. The link above is a gallery of a few of my tests.

Sometimes it did a pretty good job. Other times the results were a little more 'meh.'

The original code was pretty hacked together in PHP and a little client side JS, though I've been considering resurrecting it as a ruby gem.

There was a bug in the code in one of these examples. The 5th image or so is of a tornado with a bright orange background. The code failed to select the orange as an interesting color to use. The result still looks fine but I would have liked for it to have sampled that bit as well. It's been long enough that I can't recall what the exact problem was.



Very cool. Here's my attempt at it, which uses the JS library Color Thief: http://thomaspark.me/project/expandingalbums/


Very nice! That color thief library would have made my work a lot easier.

Here's the process I did without pasting my embarrassingly hacky code:

* Accepted image from user

* Quantized the image down to 6 main colors (I forget how I arrived at this figure.)

* Slapped it on a canvas

* Generated a color histogram

* Converted RGB to HSB

* Did a border check of the image to determine the background color. Extended the border based on most common background color if needed.

* Looked at the saturation of the colors to determine what might be interesting to use. Picked a primary and secondary color from that.

* From there I converted each of the color to YIQ to determine contrast levels to determine if I needed lighter or darker colors for the text.

* Generated some "accent" colors by modifying lightness levels of some of the primary and secondary colors.

From there I pretty much had the things I needed to make something theme-like.

Thanks for posting this. I enjoyed reading over the code. You also reminded me that I need to ditch my crappy JS tempting library that I wrote and switch to moustache.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: