我正在使用一种解决方案将图像文件组装成 zip 并将其流式传输到浏览器/Flex 应用程序。(Paul Duncan 的 ZipStream,http ://pablotron.org/software/zipstream-php/ )。
只需加载图像文件并压缩它们就可以了。这是压缩文件的核心:
// Reading the file and converting to string data
$stringdata = file_get_contents($imagefile);
// Compressing the string data
$zdata = gzdeflate($stringdata );
我的问题是我想在压缩之前使用 GD 处理图像。因此,我需要一种将图像数据(imagecreatefrompng)转换为字符串数据格式的解决方案:
// Reading the file as GD image data
$imagedata = imagecreatefrompng($imagefile);
// Do some GD processing: Adding watermarks etc. No problem here...
// HOW TO DO THIS???
// convert the $imagedata to $stringdata - PROBLEM!
// Compressing the string data
$zdata = gzdeflate($stringdata );
有什么线索吗?