Odoo Help


How to read out image_small (bytea) from hr_employee and pass to imagecreatefromstring (php)

Christian Eichert
on 2/13/14, 9:05 PM 971 views

How can I read out image_small (bytea) from hr_employee and pass to imagecreatefromtext (php) ?

// Performing SQL query
$dbconn = pg_connect("  host='".PGSQL_HOST."' 
                        password='".PGSQL_PASSWORD."' ")or die('Could not connect: ' . pg_last_error());

$query='SELECT image_small 
        FROM hr_employee 
        WHERE id='.$im;

$result = pg_query($dbconn, $query) or die('Query failed: ' . pg_last_error());
$arr = pg_fetch_array($result);


and now I have the string Then I tryed like this

$img = imagecreatefromstring($im);
if ($img !== false) {
    header('Content-Type: image/png');

say that the image cannot be displayed because it contains errors

any suggestions please ?

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 2/13/14, 9:05 PM
Seen: 971 times
Last updated: 3/16/15, 8:10 AM