Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
How to use an image from a file as a background for a canvas
-
I've been trying the following:
import canvas
from PIL import Imageim = Image.open("./myfile.jpg")
image = im.tobitmap()
canvas.draw_image(image,0,0,600,600)
I keep getting the error on the line calling tobitmp: "ValueError: Not a bitmap"
What am I doing wrong?
Thanks!
-
import canvas, clipboard, Image pil_image = Image.open('my_photo.png') clipboard.set_image(pil_image, format='png') canvas.set_size(*pil_image.size) canvas.draw_clipboard(0,0,*pil_image.size)
There must be a way to do this without the clipboard but it was beyond me.
-
Thanks, this worked!
I tried used one of the online converters to convert an image from jpg to bmp, but when I tried to use it with canvas.draw_image, it claimed that the bitmap compression wasn't supported. So, bottom line, I haven't yet been successful in getting draw_image() to work.