开发者

Convert PHP Image Object to Byte Array for AMFPHP

开发者 https://www.devze.com 2023-03-10 19:32 出处:网络
I have a PHP image object created using imagecreatetruecolor(). I\'d like to send this via A开发者_如何学GoMFPHP to Flash. I understand the best format is using a ByteArray. How can I achieve this wit

I have a PHP image object created using imagecreatetruecolor(). I'd like to send this via A开发者_如何学GoMFPHP 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


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.

<?php
$img = imagecreatetruecolor(30,40);
ob_start();
imagepng($img);
$bytes = ob_get_clean();


Do you mean something like this:

imagepng($resource);

This will send the image from the memory to the browser

0

精彩评论

暂无评论...
验证码 换一张
取 消