Sample: (run on 4.3.4)
if (is_file($filename)) { $fd = @fopen($filename,"r"); $image_string = fread($fd,filesize($filename)); $image2 = base64_encode($image_string); $image3 = base64_decode($image2); // echo strcmp($image_string, $image3); commented line 0 if($image_string <> $image3) die('not equal'); // if($image_string === $image3) die('same type'); commented line 1 if(!$image3) die('none'); // echo 'got here'; 2 $im = imagecreatefromstring($image3); //$im = imagecreatefromstring($image_string); 3 // echo 'and here'; 4 imagePNG($im, 'thisimage.png'); // echo 'and here'; 5 header('Content-type: image/png'); imagePNG($im); imagedestroy($im); fclose($fd); }
when commented line 0 is uncommented, the script outputs 0, output for strcmp in cases of equality. and 1 makes the script die('same type'). When commented line 3 is uncommented and the line before it commented out, the script works fine. When the commented echo lines are uncommented (when the script uses imagecreatefromstring($image3)), php seems to produce no output.
I'd greatly appreciate any advise on getting the image source into the php file itself, and on why this is behaving so oddly. Also: is this likely to be more load-intensive than just reading in the image files with imagecreatefrompng or fopen?
Thanks, James Coder
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php