0

I'm trying to have a jpeg image I've downloaded displayed on a screen. I'm executing the below code on a raspberry pi that'll display the shapes & image on a waveshare display. For the life of me, I can't figure this one out. For example, I've looked into the PIL library, but that's only for Windows. I've tried editing the below code. That also doesn't work. I'd greatly appreciate any code that'll help me display a jpeg image. Thank you.

import epd7in5b
import Image
import ImageDraw
import ImageFont
#import imagedata

EPD_WIDTH = 640
EPD_HEIGHT = 384

def main():
    epd = epd7in5b.EPD()
    epd.init()

    # For simplicity, the arguments are explicit numerical coordinates
    image = Image.new('L', (EPD_WIDTH, EPD_HEIGHT), 255)    # 255: clear the frame
    draw = ImageDraw.Draw(image)
    font = ImageFont.truetype('/usr/share/fonts/truetype/freefont/FreeMonoBold.ttf', 24)
    draw.rectangle((0, 6, 640, 40), fill = 127)
    draw.text((200, 10), 'UNIT INFORMATION', font = font, fill = 255)
    draw.rectangle((200, 80, 600, 280), fill = 127)
    draw.chord((240, 120, 580, 220), 0, 360, fill = 255)
    draw.rectangle((20, 80, 160, 280), fill = 0)
    draw.chord((40, 80, 180, 220), 0, 360, fill = 127)
    epd.display_frame(epd.get_frame_buffer(image))

    image = Image.open('uno.bmp')
    epd.display_frame(epd.get_frame_buffer(image))

    # You can get frame buffer from an image or import the buffer directly:
    #epd.display_frame(imagedata.MONOCOLOR_BITMAP)

if __name__ == '__main__':
    main()
1
  • What specific error do you get with this code?
    – Brick
    Feb 6, 2018 at 17:42

1 Answer 1

1

A method that would work on the Raspberry Pi would be to create a simple GUI to display the image. There is a nice Python library called appJar that allows you to make tkinter GUIs.

from appJar import gui

with gui("Image") as app:
    app.addImage("title", "image.jpg")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.