Search code examples
phpphp-gd

Add effects to an image dynamically in php


I want to add a small functionality to my site wherein a user can upload his pic and then on selecting a specific color(basically on clicking something) a splash effect of that color gets added to that image.

The user should then get an option to save that image.

Is it possible using the php GD library? Any helpful comments are welcome.

Edit: What if i create the images for these effects? how can i overlay them on the user's pic and then offer the complete image as a download?


Solution

  • The simplest way to achieve this is to create the effect in another image and just use PHPs GDlib to copy that image on the image uploaded by the user and change the color.

    You can use imagecopy or imagecopyresized or imagecopyresampled. Depending on the image you are using you could for example use imagecolorset to change the color of the effect.

    The full list of PHPs image functions is in the PHP manual.