Php gd library synthesizes pictures and uploads oss? (do not generate picture files on the server)

use gd library to synthesize pictures. How to obtain image data and upload them to oss? directly

Apr.05,2021

https://help.aliyun.com/docum.


The string of

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 .

Menu