I want to make an ebook using ebooklib that imports a cover in Python 3.4.
In Python 2 it works fine like this:
im = open('image.jpg').read()
book.set_cover(file_name=image.jpg',content=im,create_page=True)
In Python 3.4 it fails with:
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte.
Apparently reading an image via the open method no longer works but I cannot find how to do it otherwise in Python3.
I tried using codecs module:
im = codecs.open("image.jpg",'r', 'encoding='utf-8')
Result: TypeError: 'str' does not support the buffer interface
I tried using Pillow:
im=Image.open(path+'mn_epub.jpg').load()
Result: TypeError: object of type 'PixelAccess' has no len()
I also tried various other Pillow operation but I could not find anything to make it work.