Posted By

hasantayyar on 08/31/09


Tagged

phpgdimage


Versions (?)

Who likes this?

4 people have marked this snippet as a favorite

hasantayyar
NyX
umang_nine
Priestd09


Image Manipulation with PHP and the GD Library


 / Published in: PHP
 

URL: http://davidwalsh.name/php-image-filter

  1. //to black and white
  2. if(!file_exists('dw-bw.png')) {
  3. $img = imagecreatefrompng('dw-manipulate-me.png');
  4. imagefilter($img,IMG_FILTER_GRAYSCALE);
  5. imagepng($img,'db-bw.png');
  6. imagedestroy($img);
  7. }
  8.  
  9. //to negative
  10. if(!file_exists('dw-negative.png')) {
  11. $img = imagecreatefrompng('dw-manipulate-me.png');
  12. imagefilter($img,IMG_FILTER_NEGATE);
  13. imagepng($img,'db-negative.png');
  14. imagedestroy($img);
  15. }
  16.  
  17.  
  18. //to Sepia
  19. if(!file_exists('dw-sepia.png')) {
  20. $img = imagecreatefrompng('dw-manipulate-me.png');
  21. imagefilter($img,IMG_FILTER_GRAYSCALE);
  22. imagefilter($img,IMG_FILTER_COLORIZE,100,50,0);
  23. imagepng($img,'db-sepia.png');
  24. imagedestroy($img);
  25. }

Report this snippet  

You need to login to post a comment.