-1

I have this app which stores images in base 64 string in database. Storing in disk is no option here. However,

  1. I would want to choose the lightest between base 64, hex and binary. Can anyone help, please.

  2. I also appreciate conversion from base 64 to either of the other two.

I am using PHP

Stephen Adelakun
  • 784
  • 2
  • 7
  • 24

1 Answers1

0

Binary would hold the data in the smallest size, then base64 then hex.

Base64 to binary

$binarydata = base64_decode($bas64data);

binary to hex

$hexdata = bin2hex($binarydata);   

Note with binary storage you can't just echo out the image data in an <img> tag, you have to set up some kind of viewing page or just re-encode it in base64.

Musa
  • 96,336
  • 17
  • 118
  • 137