tags:

views:

168

answers:

2

I am trying to convert a string to an image using the "imagecreatefromstring" function (I've attached the code below). It works for most images, but when I try to convert larger images, a small portion of the image does not get converted (the lower part of the image is just grey)

my code is (take it from php.net example) :

            $data = base64_decode($record['text']);

            $im = imagecreatefromstring($data);
            if ($im !== false) {
                header('Content-Type: image/jpeg');
                imagejpeg($im);
                imagedestroy($im);
            }

i also try different way to decode the string not in one pice , but splitting the string and then decode it.

 for($i=0, $len=strlen($record['text']); $i<$len; $i+=4){
                $data.= base64_decode( substr($record['text'], $i, 4) );
            }
+1  A: 

It sounds like your data has been truncated, either on storage or on retrieval. Verify that you have the entire image in your store.

Ignacio Vazquez-Abrams
i check it ....
Haim Evgi
A: 

You don't need to base64 decode the string, that's probably the root of your problem.

Alix Axel
i need it i think , if i drop it is print error :Data is not in a recognized format
Haim Evgi
@haim evgi: Aren't you also base64 **encoding** the data in the first place?
Alix Axel
i edit the question , i decode only one time (one time or by split)
Haim Evgi