Is it possible to recreate images from binary data (process them if needed) and display them, all in the same script? Something like
// get and display image 1:
$imagedata1 = file_get_contents('assets/test.png');
$imagedata1 = process_using_gd_or_something($imagedata1);
echo "<img src={$imagedata1} >"; // <-- IS THIS (OR EQUIVALENT) POSSIBLE?
// get and display image 2:
//etc...
I want to avoid storing the images to to disk after processing and getting them from there, or using an external script…
You can do this using a data URI in the image
srcattribute.The format is:
data:[<MIME-type>][;charset="<encoding>"][;base64],<data>This example is straight from the Wikipedia page on data URIs: