PHP Picture Manipulation

Source: Internet
Author: User

<?php
$filename = "http://pic.nipic.com/2007-12-06/2007126102233577_2.jpg";//Picture address
Get picture information
$info =getimagesize ($filename);
Get Picture Type
$type =image_type_to_extension ($info [2],false);
Create an image of the same type as the image in memory
$fun = "imagecreatefrom{$type}";
Copy the picture to memory
$image = $fun ($filename);
Manipulating pictures
1, in memory to establish a wide 300 high 200 of the true color picture
$image _thumb=imagecreatetruecolor (150, 100);
2, copy the original image to the new true color picture, and compression according to a certain proportion
Imagecopyresampled (Dst_image, Src_image, dst_x, dst_y, src_x, src_y, Dst_w, Dst_h, Src_w, Src_h)
Imagecopyresampled ($image _thumb, $image, 0, 0, 0, 0, N, N, $info [0], $info [1]);
3. Destroying the original image
Imagedestroy ($image);
Export the picture to the browser
Header ("Content-type:". $info [' MIME ']);
$funs = "image{$type}";
$funs ($image _thumb);
Save to Hard disk
$funs ($image _thumb, "Thumb_image." $type); Imagedestroy ($image _thumb);
?>

PHP Picture Manipulation

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.