PHP text waterm...LOGIN

PHP text watermark development tutorial - open pictures

Open the picture

Open the picture, insert the picture, print out the picture information and observe

<?php
     /*打开图片*/
     //1.配置图片路径(填入你的图片路径)
     $src="https://img.php.cn/upload/course/000/000/004/581454f755fb1195.jpg";
     //获取图片信息
     $info = getimagesize($src);
     echo "<pre>";
     print_r($info);
 ?>

QQ截图20161027175710.png

Returns an array with four cells. Index 0 contains the pixel value of the image width, and index 1 contains the pixel value of the image height. Index 2 is the tag of the image type: 1 = GIF, 2 = JPG, 3 = PNG, 4 = SWF, 5 = PSD, 6 = BMP, 7 = TIFF(intel byte order), 8 = TIFF(motorola byte order), 9 = JPC, 10 = JP2, 11 = JPX, 12 = JB2, 13 = SWC, 14 = IFF, 15 = WBMP, 16 = XBM. These tags correspond to the new IMAGETYPE constant added in PHP 4.3.0. Index 3 is a text string with the content "height="yyy" width="xxx"", which can be used directly in the IMG tag.

Continue to add

//Get the type of image through the number of the image

$type=image_type_to_extension($info[2],false);//在内存中创建一个和我们图像类型一样的图像
 $fun = "imagecreatefrom{$type}";

imagecreatefromgd — from GD file or URL Create a new image

We will bring in variables later to make it more intelligent. When the image type changes, the created image will also change.

//Copy the image to our memory

$image=$fun($src);
<?php
    /*打开图片*/
    //1.配置图片路径(填入你的图片路径)
    $src="https://img.php.cn/upload/course/000/000/004/581454f755fb1195.jpg";
    //获取图片信息
    $info = getimagesize($src);
    //通过图像的编号来获取图像的类型
    $type=image_type_to_extension($info[2],false);
    //在内存中创建一个和我们图像类型一样的图像
    $fun = "imagecreatefrom{$type}";
    //把图片复制到我们的内存中
    $image=$fun($src);
?>
Next Section
<?php /*打开图片*/ //1.配置图片路径(填入你的图片路径) $src="https://img.php.cn/upload/course/000/000/004/581454f755fb1195.jpg"; //获取图片信息 $info = getimagesize($src); //通过图像的编号来获取图像的类型 $type=image_type_to_extension($info[2],false); //在内存中创建一个和我们图像类型一样的图像 $fun = "imagecreatefrom{$type}"; //把图片复制到我们的内存中 $image=$fun($src); ?>
submitReset Code
ChapterCourseware