How to load blob field image?

3

I have a binary image of a blob field and I can not read.

In the database it looks like this:

Yes,thisistheshapeofthetextimage.

Thisishowitlooks:

Itriedseveralthingsandtheonlyonethatapproachedtheexpectedresultwas:

echo'<imgsrc="data:image/jpeg;base64,'.base64_encode( $result->fields['LOGO'] ).'"/>';

That resulted in:

Blobcontenttakenfromaselect:

BM606(@@0''ÿÿÿÿÿÿøøøøøøÿÿÿÿÿÿÿÿÿèèèOOOBBBTTTTTTSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSQQQPPPPPPPPPPPPRRRTTTSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSTTTBBBOOOèèèÿÿÿÿÿÿgggEEE===,,,@@@======@@@+++>>>EEEgggÿÿÿÉÉÉ666+++    444111111444  ***666ÉÉÉ$$$     ;;;777777;;;      $$$     !!!???;;;;;;???"""  #GVLqz ¨´­gih     $$$BBB>>>>>>BBB$$$!+$/J8@cNX{eu® ¿ÌÄ   ³³³&&& '''FFFBBBBBBFFF&&&(D2.Z>6dGGqVap¡¬ÁµÐÝÖMOO*N8&K5#9+' %%%´´´ÄÄÄ---)))JJJFFFFFFJJJ((( %"*N7(Z;/'A?mQLqaOcZT[S'c'lmh'L4(a?(_=-'A0F8---ÄÄÄÑÑÑ555+++NNNJJJJJJNNN***)P7%[9+^=;iO5E=:)H$P$M K"O, 9&!A0)b@)dA.eC(5-666ÑÑÑÝÝÝ@@@...RRRMMMMMMRRR---'C2&\:'^<8bL/0)H#^/'3^/X&^/'3_2U, 1E0*iF,fC*gA2aD@@@ÝÝÝèèèKKK000VVVQQQQQQVVV000!*$([<'a=5eJ.1,O'c4'-[&rK%¢rK%[&_,g1J@/M@)N8,kD.jF,B4LLLèèèñññUUU222ZZZUUUUUUZZZ222'F2(d?/gD,@8C!f6m< |d{T5ÈÒÚ{T5|dm< e5K(&$-fC-oG3_CUUUñññúúú]]]555^^^YYYYYY^^^333!+Z<+iB4cJ-$c4n7eAÈÎÕÄÈÊÊÑ×ÃÇÊÊÑ×ÄÈÊÈÎÕe@m5g81$'R;.sI4oJ)1,]]]úúúÿÿÿiii777bbb]]]]]]bbb777,<2,fB/nF-M?=#o>t:u>ÂÀ¾ÍÑפw¤wÍÑ×ÂÀ¾u>t:o>E* :01tK4vN?YG iiiÿÿÿÿÿÿxxx"""999gggaaaaaaggg9998YC.mF2qJ)=6H' v>^.µ¤ÖÜã±s4x<s4±ÖÜ㵤_-u=R0#5/1uL4{P@jO"""xxxÿÿÿÿÿÿ%%%===lllffffffmmm>>>&O40rI5uN'84I${<«kèöÿÜàè¦Y}=P}=¦ZÜàèèöÿ¬ky;T/%613zO7S9fJ%%%ÿÿÿÿÿÿ(((@@@sssllllllsss???2Z@2vK5xO)<6J) IZ¯cãéîÌÀ²H@HÌÀ²ãéî¯cZHR1#:25R:WHlV***ÿÿÿÿÿÿ,,, !!! !!! !!!  !!!   !!!!!!CCCxxxqqqqqqxxxCCC6N>3wL5|P/K?8"JS\ßÝÛìôþÕɺº~ÕɺìôýßÝÛ\SJA+%J98W=Z;KA---ÿÿÿÿÿÿ©©©000 ###### """"""!!!!!!""""""""" ###"""!!! """$$$""" """!!!!!!FFF{{{tttttt{{{FFF '.*3rJ5R7fJ) i;WµLñøÿäáÛðõûð÷þðõûäáÛñøÿµLUo?2,,2pL;\?}X)))111©©©ÿÿÿÿÿÿµµµ444 !!!"""#########$$$"""###!!!!!!###""""""""""""###"""!!!$$$"""###$$$"""###GGGyyyyyyGGG###$##3bD7T9~S+63;"I¯fºE¦bÌ«ÿÿÿÌ«¦bºE­dIG-)C8;Y=_?fM""" 444¶¶¶ÿÿÿÿÿÿÀÀÀ888!!!###$$$$$$%%%%%%%%%######"""$$$%%%$$$$$$###$$$$$$$$$$$$%%%$$$%%%%%%$$$###KKK~~~~~~JJJ$$$$$$/D77S9W9hK,TDII(I±f²e¹zÒªn¹z²e°dMT3/648T>bDa183### 888¿¿¿ÿÿÿÿÿÿËËË;;;"""&&&%%%%%%%%%%%%%%%&&&((($$$%%%%%%%%%%%%%%%$$$%%%&&&%%%%%%%%%%%%$$$%%%(((LLLLLL&&&%%%(((6oK:Y9U9X<[HB$r?Y¨b¦[§aYuB I-187:{V@dAdAdN$$$&&&$$$<<<ÊÊÊÿÿÿÿÿÿÔÔÔ@@@%%%&&&&&&&&&((('''((('''((((((%%%&&&&&&&&&&&&''')))''''''%%%'''''''''''''''PPPPPP'''&&&&&&0=58T;[<Y9bI'''3*%C*N)S+ U/H-9316SF@]C hBgI~\,*+''''''%%%AAAÕÕÕÿÿÿÿÿÿÞÞÞDDD$$$'''((('''(((((())))))(((((()))(((((((((((()))'''&&&((('''((()))))))))'''@@@jjjeeeeeekkk???$$$'''(((3N<:U<Z;[AwT''' ¶¯j|uYkbMf[Fr_IfIkG¦lE¡iH]222((())))))%%%EEEÞÞÞÿÿÿÿÿÿçççJJJ&&&(((***+++***))))))+++((()))***+++***)))++++++)))(((***+++***)))***!!!OOO¹¹¹³³³²²²µµµµµµ²²²³³³¹¹¹LLL ***-1.0834J<9fI8fIGJHÎäÖºÞÈϱÀkµ\°}R®vL¨pJjCjR/,.******)))***'''JJJæææÿÿÿÿÿÿîîîUUU)))+++***+++***++++++++++++---+++)))+++++++++,,,***++++++***+++***+++!!!XXXÞÞÞØØØÍÍÍÃÃÃÃÃÃÍÍÍ×××ÝÝÝXXX ***+++)))+++,,,***rxt±Æ¹¦Í´Ç¥w¼g³Y¨wNgCoT7?:***+++******++++++)))WWWíííÿÿÿÿÿÿóóó___+++---,,,+++---,,,...,,,***---,,,+++,,,...---,,,+++---...+++,,,,,,---!!!WWWÚÚÚÔÔÔÄÄÄÃÃÃÃÃÃÄÄÄÓÓÓÙÙÙXXX$$$,,,,,,,,,,,,---++++++9:9U\Wh~po{[yeCRH000,,,------+++,,,,,,...++++++aaaóóóÿÿÿÿÿÿùùùjjj---------...000---...///............///......///------------111---...$$$^^^ãããØØØÙÙÙïïïîîîÙÙÙ×××âââ\\###,,,//////---//////............000///......---------...000---...---000kkkøøøÿÿÿÿÿÿýýýsss222///...///000/////////111///000///000000//////111000///...000//////###MMMÌÌÌ¿¿¿ÅÅÅÖÖÖÖÖÖÅÅÅÀÀÀËËËLLL$$$...000000/////////000///000000000000...///111000...///000//////...333tttýýýÿÿÿÿÿÿÿÿÿ666000222222///111111111111222111111333111111111111222222222000111111111hhheee000111111///222222111111222111222222000111111111222222222000111111///666ÿÿÿÿÿÿÿÿÿÿÿÿ222000111111111111222000000111111222222222333333111222111111111111...:::ÆÆÆÑÑÑÌÌÌÊÊÊÉÉÉÇÇÇÇÇÇÆÆÆÊÊʾ¾¾999...111111222111111000222222222333111333222222222111111111111222...222ÿÿÿÿÿÿÿÿÿÛÛÛWWWIIIJJJIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIHHHIIIIIIIIIIIIJJJIIIIIIIIIIIIEEEQQQÛÛÛäääÞÞÞÝÝÝÜÜÜÛÛÛÚÚÚÙÙÙÝÝÝÒÒÒQQQFFFIIIIIIIIIIIIIIIIIIIIIIIIHHHIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIHHHHHHWWWÛÛÛÿÿÿõõõkkk888ÁÁÁ÷÷÷ïïïîîîíííííííííìììòòò»»»888kkkõõõ¢¢¢999PPPöööîîîììììììììììììîîîöööPPP999¢¢¢^^^+++UUUùùùñññïïïîîîîîîîîîðððøøøUUU+++]]]PPP&&&       ZZZÿÿÿøøøõõõõõõôôôóóó÷÷÷ÿÿÿZZZ !!!     &&&QQQaaa&&& !!!""""""""""""!!!###!!!"""""""""!!!!!!"""###!!! """"""""""""!!!"""ZZZøøøöööõõõôôôôôôõõõõõõ÷÷÷ZZZ!!!!!!""""""###!!!""""""!!! !!!"""###!!!!!!""""""!!!"""!!!"""!!!"""!!!&&&bbbwww((("""###$$$$$$######$$$############$$$""""""$$$############$$$######$$$###!!!---AAAiiihhhAAA---!!!$$$"""$$$$$$###$$$"""############$$$######"""$$$#########$$$######$$$!!!(((www+++$$$$$$%%%&&&%%%%%%&&&%%%%%%$$$$$$%%%%%%%%%$$$%%%%%%%%%$$$&&&%%%%%%&&&%%%&&&"""DDD||||||FFF!!!'''%%%%%%&&&%%%%%%&&&$$$$$$%%%$$$%%%$$$%%%&&&$$$%%%%%%%%%&&&&&&%%%%%%$$$"""+++///%%%''''''((('''(((''''''&&&&&&'''((('''''''''''''''((('''''''''''''''''''''&&&PPPPPP'''((('''''''''&&&'''&&&&&&'''((('''''''''''''''''''''(((''''''''''''&&&&&&&&&...¯¯¯333''')))))))))***))))))***+++)))))))))((())))))((())))))))))))***)))*********))) TTTTTT!!!))))))))))))))))))******))))))((())))))))))))***)))))))))***)))))))))***)))'''333°°°½½½;;;***++++++***,,,,,,,,,+++,,,,,,,,,,,,++++++,,,,,,,,,+++***+++,,,---,,,+++,,,,,,###YYY      ZZZ###+++***+++,,,,,,+++,,,,,,,,,,,,+++***++++++---,,,+++******,,,,,,,,,+++,,,,,,***999½½½ÉÉÉAAA+++,,,............//////---............///.........,,,---...///......///...---%%%aaa¬¬¬££££££­­­aaa###---............//////......///...///...//////---,,,---............///......---@@@ÉÉÉÕÕÕGGG///000111111111111000111000111111111111000111111111///111111111000000000111111'''iii»»»±±±±±±»»»hhh%%%000111111000000000111000111000222111///111111111000111111111000000111000000///GGGÕÕÕàààTTT555888777777777777888888666888777666666777888777666888777777888777777888666888---qqqÉÉɾ¾¾¾¾¾ÉÉÉqqq,,,888777777666777888777777888777666777888888777777999777777777666888888666888666UUUáááëëëiiiBBBFFFGGGEEEFFFEEEFFFFFFDDDFFFFFFEEEFFFGGGFFFEEEDDDEEEGGGDDDFFFEEEFFFFFFDDDEEE;;;~~~ÖÖÖËËËËËËÖÖÖ~~~999GGGEEEEEEFFFFFFFFFEEEEEEFFFEEEDDDFFFFFFFFFEEEDDDFFFFFFEEEFFFEEEFFFFFFDDDFFFCCCiiiìììôôôVVVXXXVVVVVVZZZVVVXXXYYYXXXWWWWWWWWWXXXXXXXXXWWWXXXWWWWWWUUUYYYWWWWWWYYYYYYWWWLLLâââ××××××âââMMMWWWUUUXXXYYYVVVXXXXXXWWWWWWWWWWWWXXXXXXXXXWWWWWWXXXVVVWWWYYYVVVXXXXXXYYYWWWVVVôôôûûûiiijjjiiijjjiiiiiijjjiiikkkjjjjjjjjjjjjhhhhhhhhhkkkkkkjjjjjjiiiiiiiiiiiijjjkkk___êêêààààààêêêbbbkkkjjjjjjiiijjjiiiiiikkkiiijjjkkkiiiiiigggiiikkkjjjiiijjjiiiiiiiiihhhjjjjjjhhhûûûÿÿÿ¥¥¥xxxzzz{{{zzzxxxyyy|||xxxxxx{{{zzzyyy|||zzz{{{zzzyyy{{{{{{zzzyyywww{{{yyywwwyyyppp¥¥¥ïïïææææææïï襤¤ppp{{{{{{zzzwwwzzzzzzxxxyyyzzzyyyzzz|||zzz|||yyyyyyzzzzzzzzzxxxyyy{{{xxxwwwzzzxxx¦¦¦ÿÿÿÿÿÿ²²²}}}¬¬¬ñññééééééñññ¬¬¬²²²ÿÿÿÿÿÿ¹¹¹­­­íííååååååììì°°°¹¹¹ÿÿÿÿÿÿººº¥¥¥áááÚÚÚÚÚÚáá᧧§~~~ºººÿÿÿÿÿÿÅÅÅpppmmmooonnnmmmmmmnnnmmmnnnoooooolllnnnmmmlllooonnnnnnnnnooolllnnnmmmmmmmmmooohhhÏÏÏÈÈÈÈÈÈÏÏÏeeemmmnnnmmmnnnmmmmmmllloooooonnnllloookkkmmmooommmmmmnnnnnnmmmnnnnnnlllnnnnnnrrrÅÅÅÿÿÿÿÿÿííí]]]MMMOOOOOOQQQOOOMMMQQQMMMMMMOOOOOOOOONNNNNNOOOOOONNNOOOOOOPPPPPPMMMPPPOOOMMMGGG{{{ººº²²²²²²ºººzzzFFFNNNOOOPPPQQQMMMNNNPPPLLLNNNOOONNNNNNNNNNNNPPPOOONNNOOOOOOPPPOOOMMMQQQMMMLLL]]]îîîÿÿÿÿÿÿÿÿÿ¼¼¼666---............---...///......///...,,,,,,,,,------++++++//////------///%%%___££££££^^^%%%...---///...///******------------...---------...///---......///...---...666¼¼¼ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿËËËlllNNNMMMNNNMMMMMMNNNNNNMMMRRRCCC!!!!!!!!! !!! !!!$$$IIIQQQNNNNNNOOOFFFwww±±±ªªªªªª±±±wwwGGGOOONNNNNNQQQJJJ### !!! !!! !!!CCCRRRMMMNNNNNNNNNNNNOOONNNMMMlllËËËÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿëëëzzz||||||}}}qqq|||õõõÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿõõõ|||qqq~~~||||||zzzëëëÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿéééåååÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿåååéééÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÙÙÙRRRHHH\\hhhsss{{{{{{sssiii]]]HHHSSSÚÚÚÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ§§§¤¤¤EEE111222000///...------,,,,,,------...///000111000EEE¤¤¤¨¨¨ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ¢¢¢mmm'''dddfffgggiiijjjjjjkkkjjjjjjjjjiiigggeeeccc'''mmm¢¢¢ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿùùù¼¼¼lllYYYYYYUUUTTTRRRRRRRRRQQQQQQPPPQQQRRRSSSUUUXXXYYYjjj¼¼¼ùùùÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿðððãããÛÛÛÔÔÔÎÎÎÉÉÉÇÇÇÃÃÃÁÁÁÁÁÁÂÂÂÃÃÃÈÈÈÍÍÍÔÔÔÛÛÛãããïïïÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ

How can I read this image correctly in php?

    
asked by anonymous 16.02.2016 / 13:28

1 answer

0

As I mentioned in comment in the question I prefer to make HTTP calls to display the image instead of passing a base64 on the img element.

I do this way to show the image (s):

Controller.php :

if ($_GET['tipo'] == 'GET_FOTO_OR_IMAGE'){      
    header("Content-type: image/png");
    $codigo_exemplo = $_GET['codigo_exemplo'];
    $foto_or_image = ObjetoController::getFotoOrImage($codigo_exemplo);
    $blob_data = ibase_blob_info($foto_or_image);
    $blob_hndl = ibase_blob_open($foto_or_image);
    $image = base64_encode(ibase_blob_get($blob_hndl, $blob_data[0]));
    echo base64_decode($image);
    ibase_blob_close($blob_hndl); 
}   

ObjectController.php :

public function getFotoOrImage($codigo_exemplo){

    $connect = OpenConnection();
    $query = ibase_query($connect, "select FOTO from CAD_OBJETOS
        where CODIGO_EXEMPLO = ?", $codigo_exemplo);

    if ($query){

        $row = ibase_fetch_object($query);              
        $foto_or_image = new FotoOrImage();
        $foto_or_image->setFoto($row->FOTO);

        return $foto_or_image->getFoto();

        } else {
        return "Erro técnico: ".ibase_errmsg();
    }

    unset($query);
    unset($row);
    ibase_close($connect);          
}

HTML :

echo '<img src="Controller.php?tipo=GET_FOTO_OR_IMAGE&codigo_exemplo='.$codigo.'" />';

Avoiding this way the browser crashes if the image or photo is too large when using base64 , which was my case. And I think this might be the solution to your problem, too.

Then the call is HTTP because instead of passing a base64 pass the URL of the image in the src attribute of the img element.

    
16.02.2016 / 14:22