Home > Article > Backend Development > php generate ip on picture_PHP tutorial
In many places we will see IP addresses generated on images. Today we will tell you how to use php to generate IP addresses on images. Well, let’s take a look at examples.
In many places we will see IP addresses generated on pictures. Today we will tell you how to use PHP tutorials to generate IP addresses on pictures. Well, let’s take a look at examples.
$img = imagecreate(180,50);
$ip = $_server['remote_addr'];
imagecolortransparent($img,$bgcolor);
$bgcolor = imagecolorallocate($img, 0x2c,0x6d,0xaf); // Background color
$shadow = imagecolorallocate($img, 250,0,0); // Shadow color
$textcolor = imagecolorallocate($img, oxff,oxff,oxff); // Font color
Imagettftext($img,10,0,78,30,$shadow,"c:/windows/fonts/tahoma.ttf",$ip);
//Show background
Imagettftext($img,10,0,25,28,$textcolor,"c:/windows/fonts/tahoma.ttf","your ip is".$ip);
//Display ip
imagepng($img);
imagecreatefrompng($img);
imagedestroy($img);
In fact, it uses the image generation function of PHP. This function is often used to generate verification codes.