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)