1

I need to make an emboss effect for an image in PHP. But I need to keep the real color, like the globe picture in http://loriweb.pair.com/8udf-emboss.html

My final target is to make effect like this http://www.flickr.com/photos/52700219@N06/6729984045/in/photostream/ and I can only make it like this http://www.flickr.com/photos/52700219@N06/6759029339/ by giving grey line for each square there.

Until now, I only find emboss effect that will make the image color become gray like when using imageconvolution or IMG_FILTER_EMBOSS. How can I do this?

just2cya
  • 125
  • 2
  • 10

1 Answers1

3

The emboss effect that you showed on the "globe" example is just a generic convolution kernel. You can accomplish the same effect using imageconvolution():

$kernel = array(array(1, 1, -1), array(1, 1, -1), array(1, -1, -1));
imageconvolution($image, $kernel, 1, 0);
Russell Zahniser
  • 16,188
  • 39
  • 30
  • Wow Russel, it works !! Thank you ^^. But I need explanation, which part makes the color stay? – just2cya Feb 02 '12 at 06:56
  • Image convolution just means that each pixel in the output image is made by multiplying the nine nearby pixels by the values in the kernel. So, the kernel you are using just adds up the center pixel and all the ones up and to the left of it, and subtracts off the ones down and to the right of it, to get the final result. Based on the output, I think `IMG_FILTER_EMBOSS` was doing something different - perhaps a Sobel gradient. – Russell Zahniser Feb 02 '12 at 14:23