PHP emboss with color
Asked Answered
W

1

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?

Whittemore answered 2/2, 2012 at 3:46 Comment(0)
I
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);
Idona answered 2/2, 2012 at 4:8 Comment(2)
Wow Russel, it works !! Thank you ^^. But I need explanation, which part makes the color stay?Whittemore
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.Idona

© 2022 - 2024 — McMap. All rights reserved.