I receive an Image through my form, which I not want to save as usual in a FileField
but in a CharField
as Base64. This is my current setup:
Yes it's possible to do it easily with PIL !
Save image in the buffer and encode it in base64.
import base64
import cStringIO
img_buffer = cStringIO.StringIO()
image.save(img_buffer, format="imageFormatYouWant")
img_str = base64.b64encode(img_buffer.getvalue())
with open("yourImage.ext", "rb") as image_file:
encoded_string = base64.b64encode(image_file.read())