0

I am trying to access image which is saved as blob, and the type of column is image which is saved using c# in mssql

While retrieving image is showing correctly using c# code

While accessing using php the image is broken

code which i have tried

 $image = imagecreatefromstring($stationDetail->cstatpic3); 
 ob_start();
 imagejpeg($image);
 $data = ob_get_contents();
 ob_end_clean();
  echo '<img src="data:image/jpeg;base64,' .  base64_encode($data)  .     '" />';
 exit; 
also from this link

PHP display image BLOB from MySQL

Shibon
  • 1,552
  • 2
  • 9
  • 20
  • Unless the image you stored is _not_ a JPEG already, it makes rather little sense to use `imagecreatefromstring` followed `imagejpeg`. (What you receive from the database would need to be valid, binary image data to begin with, otherwise `imagecreatefromstring` could not do anything with it. But if you have valid, binary image data already, you could encode that as base64 directly, without the “detour” via `imagecreatefromstring` and back using `imagejpeg`.) – misorude Jul 05 '19 at 10:29
  • What have you done so far to actually debug this then? Have you at least checked what the generated HTML code looks like? Or verified that `$image` is a valid GD image resource? – misorude Jul 05 '19 at 10:30
  • @misorude image will be half so.. it is a valid GD image resourc – Shibon Jul 05 '19 at 10:31

0 Answers0