将图像转换为字符串而不保存图像

I know that there is quite a lots this question on stack overflow but I don't think my question is the same.

I want to convert an Image resource to a string without having to save the image to the disk.

Is there a function for that, that im am not aware of and that i did not got able to find in the pass hour of searching Google.com

You can use any of the image* functions that output an image as a stream and use output buffering to capture it:

ob_start();
// example for jpeg
imagejpeg($resource);
$image_string = ob_get_contents();
ob_end_clean();