简体   繁体   中英

PHP: How can I create a (PNG, JPEG or GIF) image and encode it directly in base 64 without saving it?

I have a script that creates an image. I have to make a common format like GIF, JPEG or PNG out of it and convert it to base 64, later on.

When doing this, I do not want to save the image on the server, nor I want any browser output. So imagepng() seems not right command for this.

Any ideas?

If all else fails, you can always do this:

ob_start();
imagepng($resource);
$png = base64_encode(ob_get_clean());

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM