PHP development picture watermark tutorial - opening pictures
<?php /*打開圖片*/ //配置圖片路徑 $src = "https://img.php.cn/upload/course/000/000/004/581454f755fb1195.jpg"; //獲取圖片的基本信息 $info=getimagesize($src); //通過圖像的編號(hào)來獲取圖片的類型 $type=image_type_to_extension($info[2],false); //內(nèi)存中創(chuàng)建一個(gè)和我們圖像類型一致的圖像 $fun = "imagecreatefrom{$type}"; //把要操作的圖片復(fù)制到內(nèi)存中 $image=$fun($src); ?>
The first step of adding a picture in php is the same as adding text. Open the picture, read the file information, get the type of the picture, and then create an identical picture in the memory.