php - Change image colors with GD -


I want to know about the manipulation of images in PHP and want to write some code to edit photos.

I'm reading about the imagefilter () function, but I want to manually edit the callers.

I have a little image with imagefilter to seperate an image

  Imagefilter ($ image, IMG_FILTER_GRAYSCALE); Imagefilter ($ image, IMG_FILTER_COLORIZE, 55, 25, -10); Imagefilter ($ Image, IMG_FILTER_CONTRAST, -10);   

I want to do this, but without the image file (); it's possible?

I understand that it is getting color in the image and then can change it and paint it again;

I have this to get the image color: $ rgb = imagecolorat ($ out, 10, 15); $ Colors = imagecolorsforindex ($ out, $ rgb);

and prints it:

  array (4) {["red"] => Int (150) ["green"] = & gt; Int (100) ["blue"] = & gt; Int (15) ["alpha"] = & gt; Int (0)   

}

Can I edit those values ​​and integrate them into the picture?

I appreciate any help: books, tutorials, code pieces

function. Since this function requires a third parameter as a color identifier that you need to use to create one.

Here is an example code that reduces the color values ​​of each color:

  $ rgb = Imagecolorat ($ out, 10, 15); $ Colors = imagecolorsforindex ($ out, $ rgb); $ New_color = imagecolorallocate ($ out, $ color ['red'] / 2, $ color ['green'] / 2, $ color ['blue'] / 2); ImageSetset ($ out, 10, 15, $ new_color);   

Here's a simple grayscale filter:

  list ($ width, $ height) = getimagesize ($ filename); $ Image = imagecreatefrompng ($ filename); $ Out = imagecreatetruecolor ($ width, $ height); {$ Y = 0; $ Y & lt; $ Height; For $ y ++} {{$ x = 0; $ x  imagecolorallocate  inside a loop, you assign more color instead of  imagecolorstotal  inside of an image can not do. If you have reached the limit, then  imagecolorallocate  will return false and you can use the closet to get the color that has already been allocated.   

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -