イメージファイルをzipにアセンブルし、ブラウザ/ Flexアプリケーションにストリーミングするソリューションを使用しています。 (ZipStream Paul Duncan著、http://pablotron.org/software/zipstream-php/)。PHP GD:imagedataをバイナリ文字列として取得するには?
イメージファイルを読み込んで圧縮するだけで正常に動作します。ここでは、ファイルを圧縮するためのコアがあります:
// 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);
手がかりはありますか?
ob_get_clean()は、本質的にので、)(ob_get_contents()およびob_end_cleanの両方を実行しますこの解決方法は、上記の答えが少し上品です。 –