Muffinresearch Labs by Stuart Colville

Pickr: colour palettes from photography | Comments (7)

Posted in Code on 7th November 2005, 2:10 am by Stuart

Pickr is a small demonstration of javascript’s ability to leverage server-side libraries using XMLHttpRequest. In this case the client-side script is making use of the GD library on the server side. The co-ordinates of the on-click are generated by working out the offset of the image in relation to the viewport. These co-ordinates are then sent to a PHP script (via XMLHttpRequest) which returns the RGB value of the pixel using the GD graphics library. Subsequently the “holder’s” background color is changed to match the value of that pixel.

If javascript is turned off on the browser the script degrades to using PHP sessions and GET requests to replicate the client side functionality. The image is a form input in order to retrieve the X and Y co-ordinates of the image where it was clicked and these are passed to GD to work out the colour information for that pixel

Althought this is purely a demonstration there are a few possible applications for this script. One would be to extend the script to allow users to upload photos to create palettes of colours from the photography. Also one idea I had (which is the reason for the script’s name!) would allow the user to retrieve pictures from their flickr account to create colour schemes. If nothing else, it shows that it should be possible to access anything that the GD library can do from the client side.

Check out the Pickr Demo here

Post Tools

Comments: Add yours

1. On November 7th, 2005 at 8:14 am Tim said:

Still looking good Stu – great choice of photo, although the Monkey noise one would have been funnier… ;)

I still think the reset button needs work.

And where’s the link to the files? >makes a note – “does not share toys”

2. On November 23rd, 2005 at 2:24 pm Stuart said:

Will sort out a download of the files some point in due course ; )

3. On December 6th, 2005 at 9:33 pm Timothy Wood said:

This is an awesome concept – one suggestion I’d love to see is a method to display either a list of the codes selected or next to each icon as they are selected – some way to quickly grab the codes for a photoshop swatch.

4. On December 7th, 2005 at 8:50 am Stuart said:

@Timothy: Yes great idea, I will add your suggestion in the next iteration at the same time as providing the source for download.

5. On April 28th, 2007 at 4:03 pm Dave said:

Hi would love to see how this works did you ever release the source?

6. On June 25th, 2007 at 7:03 pm R Wysong said:

Ditto. I was just looking for the source myself.

7. On February 27th, 2009 at 4:42 pm hex said:

is it available for download? please e-mail me. great work btw.







XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>



Using Loggerhead with mod_wsgi|(0)

Here’s a post I wrote over on the Project Fondue Blog about our use of Loggerhead with mod_wsgi under Apache. Loggerhead is the rather nice branch viewer for bazaar branches as used on Launchpad.net.

If you’re not already subscribed to the Project Fondue blog feed then I can recommend it, as there should be some interesting posts coming out of there in the coming months (yes I’m unashamedly biased!).

Ubuntu: Turn off changing workspace with mouse wheel|(1)

I found the changing with the workspace with the mouse wheel really annoying. To disable it go to System => Preferences => CompizConfig (available if the compizconfig-settings-manager package is installed) and uncheck “Viewport Switcher” which is under the “Desktop” heading.

Photos on Flickr

© Copyright 2004-10 Stuart Colville, all rights reserved. May contain traces of Muffin. Powered by WordPress. Hosting by Slicehost.com This page was baked in 0.656s.