Take the 2-minute tour ×

I have a PHP image object created using imagecreatetruecolor(). I'd like to send this via AMFPHP to Flash. I understand the best format is using a ByteArray. How can I achieve this without writing the image to the disk?

Thanks, Josh

share|improve this question

2 Answers 2

You cannot transfer the raw resource, but the usual course of action is to use an ob_start() before the imagepng/imagejpeg/imagegif functions, and get it in a variable with ob_get_clean(). How it works with AMFPHP & ByteArrays is another matter, I have no experience with those.

$img = imagecreatetruecolor(30,40);
$bytes = ob_get_clean();
share|improve this answer
can you give me some example code for this. the amfphp bit i'm fine with. –  Josh Jun 5 '11 at 23:22
There you go, edited it in. –  Wrikken Jun 5 '11 at 23:24
Flash doesn't recognise the result as a valid ByteArray - any other ideas? –  Josh Jun 6 '11 at 9:56
I have no clue what that expects as input. Any quick docs on that? (and it isn't a ByteArray yet, you do something like $barr = new ByteArray($bytes); I hope?). –  Wrikken Jun 6 '11 at 11:52

Do you mean something like this:


This will send the image from the memory to the browser

share|improve this answer

Your Answer


