• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 218
  • Last Modified:

image manipulation with php and javascript

Hi Experts,

Looking at this site:

http://www.stripegenerator.com/

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?
0
maccaj51
Asked:
maccaj51
  • 2
  • 2
2 Solutions
 
EthienCommented:
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
imagedestroy($im);

Open in new window

0
 
VampireofdarknessCommented:
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.
0
 
maccaj51Author Commented:
Thanks for both of your help... is there anyway to create gradients??
0
 
VampireofdarknessCommented:
Does this help? http://www.hawkee.com/snippet/5022/

Untested.
0
 
maccaj51Author Commented:
HEROIC!!! Many thanks to you both!!!!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now