Search code examples
phpgenexus

Read content of IMAGE attributes outside of GeneXus


In GeneXus I store an image in an Image type attribute, in SQL Server that field is VARBINARY(MAX) and the content is:

"0x89504E470D0A1A0A000000..."

I understand that it is the HEXA of the binary. What I want to do is to be able to raise that image outside of GeneXus, in this case PHP How does GeneXus store that image? Because I tried to convert that HEXA to String and then to BASE64 but I couldn't find the content and display the image.


Solution

  • Fixed!

    <?php
    // Value of Image Data Type
    $imagen = '0x89504E470D0A1A0A0000000D49484...';
    ?>
    
    <img src="data:image/png;base64,<?php echo base64_encode(pack('H*',substr($imagen, 2)));?>" />
    

    Cheers