I am looking to create embedded base64 encoded image data for display in a table using canvases. Python generates and creates a web page dynamically. Because this means that python uses the Image module to create thumbnails. After creating all the thumbnails, Python then generates the base64 data of each thumbnail and puts the b64 data in hidden gaps on the user's web page. The user then clicks the marks on each thumbnail regarding their interest. Then they create a PDF file containing the selected images by clicking the pdf generation button. JavaScript using jsPDF generates hidden data in the b64 range to create image files in a pdf file, and then, ultimately, in a pdf file.
I hope that we can reduce the execution time of the Python script and minimize some disk I / O by generating base64 sketch data in memory when the script is executed.
Here is an example of what I would like to accomplish.
import os, sys import Image size = 128, 128 im = Image.open("/original/image/1.jpeg") im.thumbnail(size) thumb = base64.b64encode(im)
This does not work sadly, get TypeErorr -
TypeError: must be string or buffer, not instance
Any thoughts on how to do this?
python base64 python-imaging-library
0xhughes
source share