How to save images generated by PHP

Source: Internet
Author: User
How to save the PHPcode $ targ_w = $ targ_h = 150; // The size of the saved image $ export _quality = 90; $ src = '/image/abc.jpg '; $ img_r = imagecreatefromjpeg ($ src) how to save the image generated by PHP
PHP code
  $ Targ_w = $ targ_h = 150; // The size of the saved image $ pai_quality = 90; $ src = '/image/abc.jpg'; $ img_r = imagecreatefromjpeg ($ src ); $ dst_r = ImageCreateTrueColor ($ targ_w, $ targ_h); imagecopyresampled ($ dst_r, $ img_r, 0, 0, $ _ POST ['x'], $ _ POST ['Y'], $ targ_w, $ targ_h, $ _ POST ['w'], $ _ POST ['H']); header ('content-type: image/jpeg '); imagejpeg ($ dst_r, null, $ pai_quality); ImageDestroy ($ dst_r );

Now the image is displayed normally.
1: Why is the service provider abc123.jpg automatically available?
2: save another 50*50 screenshots for abc123456.jpg.


------ Solution --------------------
No output. save it as a file. you only need to modify the second parameter of imagejpeg () to the file name. Therefore, Header () is not required to declare the output stream.
Save the thumbnail. For more information, see the imagecopyresampled () function.
------ Solution --------------------
1,
Bool imagejpeg (resource $ image [, string $ filename [, int $ quality])
The second parameter specifies the file.

2,
Bool imagecopyresized (resource $ dst_image, resource $ src_image, int $ dst_x, int $ dst_y, int $ src_x, int $ src_y, int $ dst_w, int $ dst_h, int $ src_w, int $ src_h)

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.