use gd library to synthesize pictures. How to obtain image data and upload them to oss? directly
use gd library to synthesize pictures. How to obtain image data and upload them to oss? directly
https://help.aliyun.com/docum.
PHP is binary safe, and the binary data can be saved directly into the string.
Functions such as imagepng
and imagejpeg
of GD are directly output to the browser when the file path is not set. We can use the Output Control function to intercept the output stream.
ob_start(); //
imagepng($image); //
$imagebin=ob_get_contents(); //
ob_end_clean(); //
The content in $imagebin
is the same as the binary data that is saved to a file and read with file_get_contents
.