When written directly to xlsx file, insert_image works as intended. But it doesn't work when written to BytesIO object, the image simply doesn't appear.
Asked
Active
Viewed 630 times
1
-
You will need to add an example that shows it not working. Here is an [example](https://xlsxwriter.readthedocs.io/example_images_bytesio.html) from the from the XlsxWriter documentation that shows `insert_image()` working with BytesIO. – jmcnamara May 21 '20 at 12:37
1 Answers
1
Ok, I had to actually specify image_data parameter for this to work using byte stream.
img = 'img.png'
image_file = open(img, 'rb')
image_data = io.BytesIO(image_file.read())
image_file.close()
ws_dashboard.insert_image('A1',img, {'image_data': image_data, 'x_scale': 0.5, 'y_scale': 0.5})

thethakuri
- 509
- 5
- 16