Already posted go back a couple pages.

Ive tested on PHP6

PHP Code: 
<?
    $im 
= new ImageContainer('file.txt','image');
    
$im->CreateSplit(1024*50);//50kb split.
    /*
    Note: this is filesized splits not the output image size, the output size will depend on compression, if its text you can expect a output size of roughly 20% of the file
    else if its actually binary you can expect around 20% overhead.
    */

    
$im2 = new ImageContainerExtract('image0.png');
    
$im2->Extract_File('php://output');
    
error_reporting(E_ALL);

    class 
ImageContainer {
        private 
$file '';
        private 
$number_total 0;
        private 
$out '';

        function 
ImageContainer($file,$out){
            
$this->file $file;
            if(!
file_exists($file)){
                throw new 
Exception('File does not exist');
            }
            
$this->out $out;
        }

        function 
CreateSplit($split){
            
$fs filesize($this->file);
            if(
$split>$fs){
                
$split $fs;
            }
            
$this->number_total ceil($fs/$split);//Total number of splits
            
$fp fopen($this->file,'rb');
            
$i 0;
            while(
$fs>0){
                
$h $w floor(sqrt($split));
                
$h += ceil((sqrt($split)-$w)/$w);
                
$fs -= $h*$w;
                
$this->file2image($i,$fp,$this->out.$i.'.png',$w,$h,$split);
                
$i++;
            }
            
fclose($fp);
        }

        function 
file2image($split_no,$fp,$image,$w,$h,$split){
            
$header '[I]'.dechex($split_no).'.'.dechex($this->number_total).'.'.base64_encode(basename($this->file)).'|';
            if(
strlen($header)>$w*$h-$split){
                
$h++;
            }

            
$gd imagecreate($w,$h);

            
$color = array();
            for(
$i=0;$i<=255;$i++){
                
$color[$i] = imagecolorallocate($gd,$i,$i,$i);
            }
            
$wc $hc =0;        

            for(
$hc=0;$hc<$h;$hc++){
                for(
$wc=0;$wc<$w;$wc++){
                    
$r '';
                    if(
$header) {
                        
$r=$header{0};
                        
$header substr($header,1);
                    }else 
$r fread($fp,1);
                    
imagesetpixel($gd,$wc,$hc,$color[ord($r)]);
                }
            }
            
imagepng($gd,$image,9,PNG_NO_FILTER);

            
imagedestroy($gd);
        }
    }

    class 
ImageContainerExtract {
        private 
$file '';
        private 
$efile '';
        private 
$data = array();
        private 
$parts 1;

        function 
ImageContainerExtract($file){
            
$this->file $file;
            
$this->data[0] = $this->decode_image_raw($file);
            
$part_number $this->ReadHeader(0,true);
            if(
$part_number!==0){
                throw new 
Exception('Not first part.');
            }
            for(
$i=1;$i<$this->parts;$i++){
                
$filen str_replace('0.png',$i.'.png',$file);
                
$this->data[$i] = $this->decode_image_raw($filen);
            }
        }

        function 
ReadHeader($index,$strip=true){
            
$mark substr($this->data[$index],0,3);
            switch(
$mark){
                case 
'[I]':
                    
$endof strpos($this->data[$index],'|');
                    
$header substr($this->data[$index],0,$endof);
                    if(
$strip){
                        
$this->data[$index] = substr($this->data[$index],$endof+1);
                    }
                    list(
$part_number,$this->parts,$this->efile) = explode('.',$header);
                    
$part_number hexdec($part_number);
                    
$this->parts hexdec($this->parts);
                    
$this->efile base64_decode($this->efile);
                    return 
$part_number;
                    break;
            }
        }

        function 
decode_image_raw($image){
            
$ret '';
            
$gd imagecreatefrompng($image);
            list(
$w,$h) = getimagesize($image);
            for(
$ih=0;$ih<$h;$ih++){
                for(
$iw=0;$iw<$w;$iw++){
                    
$rgb imagecolorat($gd,$iw,$ih);
                    
$ret .= chr($rgb);
                }
            }
            
imagedestroy($gd);
            return 
$ret;
        }

        function 
Extract_File(){
            
$fp fopen($this->efile,'wb');
            foreach(
$this->data as $d){
                
fwrite($fp,$d);
            }
            
fclose($fp);
        }
    }
?>