Jump to content

Using File Put contents with BLOB Image data


DrTrans

Recommended Posts

I have a base64 encoded image -> http://pastebin.com/698ES5t0

 

Im trying to export this as a png file.

 

 

 
  $picture =  {data on paste bin}; 
 
 
 $picture = base64_decode($picture); 
 
file_put_contents('/home/picture.png', $Picture);
 
 

 

 

Now this creates a file picture.png and i can open it in Preview/Gimp etc.   However, if i upload the file to my website, the image does not render in chrome/firefox, however it does render in Safarai. 

 

It seems that there is no height/width/depth data.

That's a JPEG 2000 image, not PNG. You can't just name a file what you want and expect it to work.

 

With that said, renaming with the appropriate extension (a) isn't enough because there's more to the issue than just the extension and (b) really isn't enough because it's JPEG 2000 and that format isn't commonly supported.

Convert it to a different format.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.