image manipulation with php and javascript

Posted on 2011-05-04
Last Modified: 2012-05-11
Hi Experts,

Looking at this site:

is there any way to generate or manipulate colours in an image... So users can change the colour of stripes or gradients on my site?
Question by:maccaj51
    LVL 2

    Accepted Solution

    Use the PHP image library. Here is an example from source-forge.
    $imgname = "test.gif";
    $im = imagecreatefromgif ($imgname);
    $index = imagecolorclosest ( $im,  255,255,255 ); // get White COlor
    imagecolorset($im,$index,92,92,92); // SET NEW COLOR
    $imgname = "result.gif";
    imagegif($im, $imgname ); // save image as gif

    Open in new window

    LVL 9

    Expert Comment

    To allow javascript interaction you will most likely pass variables from javascript to a .php image (<img src='./image.php?var1=1&var2=2' style='...'/>).

    You then use the image library, as above, with those variables to output the image. To change the background you'll need to change the background image for your site.

    IF YOU ARE ALLOWING USER INPUT TO INFLUENCE YOUR PHP SCRIPTS, make sure to validate and sanitize any and all accepted inputs before using them.

    Author Comment

    Thanks for both of your help... is there anyway to create gradients??
    LVL 9

    Assisted Solution

    Does this help?


    Author Closing Comment

    HEROIC!!! Many thanks to you both!!!!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
    This article covers the basics of the Sass, which is a CSS extension language. You will learn about variables, mixins, and nesting.
    The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
    The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now