Q:

Base64 - Encoding and Decoding

I am converting my image into Base64 on the android client
What i have tried ::

I googled for Base64 here
But i couldn't understand it much clearly

My Questions::

Base64 is this a image format like JPG & PNG ?
Or Base64 is just a encoding/decoding scheme ?
If Base64 is just a encoding/decoding scheme, what format the image
will be when JPG is Base64 encoded. i mean will it it be JPG format
still and just encoded as Base64 ?
What relationship exists between Base64,JPG,PNG ?
Also if the strings are Base64 encoded what format should we need to
decode it to be human readable

Hope i am clear with my question

A:

Base64 is a encoding/decoding scheme as stated in your link.
You can convert Bytes into Base64 String representation, this allows you to Save e.g. an Image as a (Base64) String.
The Format of the Data doesn´t matter at all (you can convert jpg, png, gif...),
this means you encode Bytes to a String and then if you decode this String you get exactly the same Bytes as before (same format).
A workflow would be:

Create an Image
Save Image as JPG
Encode JPG Image as Base64 String
Stream the String over some Network
Decode Image from Base64 String on the receiver side
show Image

Why do we encode at all? Because Strings are easier to use in HTML, Email and so on.
Example:
This is an Example of Base64 Encoding and Decoding using Python. It loads an Image, Encodes it, Decodes it and than saves the Data as an Image.
import base64

# load image and encode
jpgBase64String = base64.encodestring(open("test.jpg", "rb").read())

# work with jpgBase64String (e.g. send over Network)
[...]

# decode
image = base64.decodestring(newjpgtxt))

# write to File
f = open("test2.jpg", "w")
f.write(image)
f.close()

