KrisWillis.com

Flower

Posts Tagged ‘colour’

Recolouring images with PHP

Blue roseAbout a year ago I was working on a project where one of its features allowed the user to upload an image, select a colour on the image with a colour picker tool, then select from a group of colours to replace the picked colour with. I had a somewhat stable build running where it simply replaced the hue of the picked colour – Introducing saturation and value changes invoked a number of ‘random’ glitches and odd colour effects. This feature was subsequently dropped from the project due to it costing too much to continue developing.

Skip forward about a year and I find this script knocking around on a back-up disc, so I decide to put some more development time in purely for my own satisfaction of enhancing it. I have made it work to a nearly passable level, it works nice on images with isolated high contrasting colours. I created a function to create a tiled pop-arty graphic from an inputted image too just for fun. For example, input this and it will spit out this. There is plenty of room for improvement: You can’t convert colours to or from white/black and it replaces all instances of a colour, not a flood-fill effect. So, on to the code… (more…)