I'm trying for 2 days to find a way to retrieve some images from a database. They are saved as a binary string (I read the term somewhere, but frankly never heard before).
Most of the images are in
.jpeg format and is easy to get and save to a file. but my problem is the
.bmp images. For some reason i can't show then.
For now, i'm using a simple code just to get the image and save it to a file:
$img = $row['image']; file_put_contents("file.jpeg", $img); //Doesn't matter what format i put there.
Works fine in
.bmp formats are unreadable when i try to display.
Things i already found and didn't solved:
Reason: Both try to convert the image, but some parts are missing, turning black.
Btw, i'm not sure if this will affect the question, but in my project im using this library https://github.com/Intervention/image, and only with this i can see the "semi conversion" of the images. With the
file_put_contents() it still unreadable. So my actual code is like this:
$img = Image::make(imagecreatefrombmpstring($item['image'])); $filename = __DIR__ . '/test.jpeg'; $img->save($filename);
I used before this solution below to check if the images i have are
And they are. I could easily adapt this and correct my file output format, but this is not my real problem. My problem is the
.bmp files, for some reason, are not showing.