I think in the process of learning, we should know "play", make a sense of accomplishment, so that the effect of learning and enthusiasm will be very high,
Would like to learn more about their own things!
To illustrate:
Today, we learned some of the functions of PHP's image function, and they were:
GetImageSize ()
Array getimagesize (string $filename [, Array & $imageinfo])
The getimagesize () function will determine any GIF,JPG,PNG,SWF,SWC,PSD,TIFF,BMP,IFF,JP2,JPX,JB2,JPC,XBM or WBMP The size of the image file and returns the size of the image as well as the file type and a height/width text string that can be used in an IMG tag in an ordinary HTML file.
Imagecreatefromgif ()
Resource Imagecreatefromgif (String $filename)
Imagecreatefromgif () returns an image identifier that represents the image obtained from the given file name.
This function returns a handle to an operation in order to facilitate the use of this image resource.
Similar functions also have imagecreatefromjpeg (), Imagecreatefrompng () Of course there are many, you can read the official online manual
Imagecolorat ()
int Imagecolorat (resource $image, int $x, int $y)
Returns the color index value of the pixel at the specified position in the drawing specified by image.
Imagecolorsforindex ()
Array Imagecolorsforindex (resource $image, int $index)
This function returns an associative array of key names with Red,green,blue and alpha, containing the corresponding values for the specified color index.
We have seen a blunt introduction, estimated sleepy, but please stick to it!
How do you practice after you have learned these functions?
In fact, I learned these functions, immediately thought of a very fun thing to do!
What is it? Guess what, ~!!!!.
Look at the code:
$url = "Logo-yy.gif";
$size = getimagesize ($url);
$width = $size [0];
$height = $size [1];
$im = Imagecreatefromgif ($url);
for ($y =1; $y < $height; $y + +) {
for ($x =1; $x < $width; $x + +) {
$color _index = Imagecolorat ($im, $x, $y);
$color _tran = Imagecolorsforindex ($im, $color _index);
Echo (" ");
Echo ("Love");
Echo ("");
}
Echo ("
");
}
?>
Note that the function used in my program is Imagecreatefromgif ()
So the variable, the file that the Imagecreatefromjpeg point should be in GIF format, if you want to point to the JPG format file to use the ()
Of course we can write together, because the first function can determine the format of the picture, I do not write here!! Ha ha
Well, there is a PHP environment to try what it is! Oh
It is not recommended to use too big pictures! Small logo on the good!
Otherwise, don't blame me for not telling you!
This example has no practical use!! But he can inspire everyone to learn the fun!!
Dedicated to people who are learning PHP!
The above is introduced to learn PHP needs divergent thinking to learn PHP, including the content of learning PHP, I hope that the PHP tutorial interested in a friend helpful.