PHP from zero single row (18) Image processing

Source: Internet
Author: User
Tags add format array copy empty header image identifier imagejpeg

1. Open a picture that already exists

 
  
The parameter of the function Imagecreatefromjpeg () is the path where the file is located, and the return value is the resource identifier of the picture that the parameter refers to. This function creates a new image from an existing image and does not simply open the original image itself. If you change the picture's suffix name. jpg to. png, you cannot open the file even with the function imagecreatefrompng (), because the picture is essentially a JPG image.

2. Get the related properties of the picture

 
  $x pixels ";
echo "
"; echo "
"; echo "Picture Cc.jpg high for:$y pixels"; ? >

In addition, through a function not belonging to the GD Library getimagesize (), you can get the size of the picture and other related properties, the function of the syntax is as follows:

Array getimagesize (string $filename [, array &imageinfo])

 
  ";	
	}
? >
The third element is the format of the picture, and its value means the following:

1: The picture is GIF format

2: Indicates that the picture is in JPG format

3: The picture is in PNG format

4: The picture is SWF format

5: Indicates that the picture is PSD format

6: The image is BMP format

 
  
"
 
   >

3. Add the watermark effect to the picture

• Get the width and height of the picture you want to add a watermark to

• Determine whether the picture size meets the watermark text size

• Determine the position of the watermark effect in the picture

• Set the color blending mode of the image

• Create a watermark effect

• Releasing resources

 -->0) {$uploadfile = "./". Time (). "
_ ". $_files[' userfile ' [' name ']; if (copy ($_files[' userfile '] [' tmp_name '], $uploadfile)) {Makeimagewatermark ($uploadfile, 2, "Photo by Mac", 16, "#
	43042A ");	
	echo ""; else {echo "uploadwrong!
"; }}?> <title>19.9.php</title> Select Upload Picture:

4. Generate thumbnails of existing pictures
 
  
The first and second parameters are the target image, the original image identifier, the next 4 parameters are the destination image and the original image copy location coordinates, the last 4 parameters are the destination image and the original image of the replication area of the width of the height.
!! Using the function imagecopyresampled () function
 
  






Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.