简体   繁体   English

将GD图像转换回二进制数据

[英]Convert GD image back to binary data

I have a GD image resource created from imagecreatefromstring . 我有一个从imagecreatefromstring创建的GD图像资源。 After some image operations, I want to convert it back to binary data. 经过一些图像操作后,我想将其转换回二进制数据。 How would I do this? 我该怎么做? Can't see any functions in the manual... 看不到手册中的任何功能......

Use imagejpeg , imagepng , or similar. 使用imagejpegimagepng或类似的。 Use output buffering if you want to dump the result to a string, rather than a file: 如果要将结果转储到字符串而不是文件,请使用输出缓冲

ob_start();
imagejpeg($im);
$image_string = ob_get_contents();
ob_end_flush();
function image_data($gdimage)
{
    ob_start();
    imagejpeg($gdimage);
    return(ob_get_clean());
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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