Tag:php
Article From:https://segmentfault.com/q/1010000012154165
Question:

bool imagefill ( resource $image , int $x , int $y , int $color )

imagefill() In the coordinates x of the image image, the Y (0, 0) in the upper left corner of the image is filled with the color color (that is, the color is the same as X, the Y point is the same and the adjacent points are filled).

I understand, but there will be BUG in actual operation. I don’t know whether it is browser compatibility or PHP version.


AA.JPG

The size of each color block is 50px*50px


<?php
$im = imagecreatefromjpeg(“AA.jpg”);
$blue = imagecolorallocate ( $im, 0, 0, 255 ); // Set a color variable to be red

imagefill ( $im, 30, 80, $blue ); // Set the background red
//imagefill ( $im, 0, 0, $blue ); // Set the background red

header ( ‘Content-type: image/jpg’ ); // Notifying the browser that this is not a text but a picture
imagepng( $im ); // Generate PNG format images to the browser

imagedestroy ( $im ); //Destroy image resources and release the memory space occupied by the canvas.
?>


The output picture is like this

Answer 0:

Not how to use this function, but

$blue = imagecolorallocate ( $im, 0, 0, 255 ); // Set a color variable to be red

rgbThe colors are red red green green blue blue, so you are blue, not red.

Answer 1:

Yes, I modified the code, and I forgot to change the note.

Similar Posts:

Leave a Reply

Your email address will not be published. Required fields are marked *