Hi everyone! in my project I receive from a server with post call, a base64 string that contains an image that I convert and display without problems. The image is in jpg format, I should also be able to accept png formats, but I don't understand if there is a way to understand from the base64 string or with some other way if the image I receive and I'm about to convert is in jpg format or png Can anyone give me some advice? Thank you all
JPEG file headers typically begin with bytes FF D8 ("/f8=" to B64), PNG file headers begin with a fixed 8-byte signature: 89 50 4E 47 0D 0A 1A 0A ("iVBORw==" to B64)
You have to look for these after you transform to the normal format
JPEG file headers typically begin with bytes FF D8 ("/f8=" to B64), PNG file headers begin with a fixed 8-byte signature: 89 50 4E 47 0D 0A 1A 0A ("iVBORw==" to B64)
You have to look for these after you transform to the normal format
Thank you! However, I receive the image string encoded in base64, does the same thing you suggested apply? or do I have to transform it into bytes? Thank you!
Thank you! However, I receive the image string encoded in base64, does the same thing you suggested apply? or do I have to transform it into bytes? Thank you!
An alternative could be that the server also returned the mimetype (or at least the extension), together with the base64. In that case you wouldn't have to analyze the data on the client.