Skip to main content

Inkplate 6COLOR – Draw Image from Web

Example showing how to connect to WiFi and render an image fetched from URL using draw_image.

ℹ️
Supported image formats: JPG, BMP, and PNG.
⚠️
JPG files without progressive encoding are supported.
ℹ️
If you experience issues displaying an image, try re-saving it with an image editing program. The issue is usually related to the image format.

Drawing an image

Example image to show on inkplate
Example image
# Include needed libraries
import network
import time
from inkplate6_color import Inkplate

# WiFi credentials (replace with your own)
SSID = "YOUR_SSID_HERE"
PASSWORD = "YOUR_PASSWORD_HERE"


# Connects to a WiFi network using given SSID and PASSWORD.
#
# Returns:
# - True if successfully connected
# - False if connection fails within the timeout period
#
# Notes:
# - Timeout is set to 30 seconds
# - Prints network IP config on success
def do_connect():
sta_if = network.WLAN(network.STA_IF)
if not sta_if.isconnected():
print("Connecting to network...")
sta_if.active(True)
sta_if.connect(SSID, PASSWORD)

timeout = 30 # seconds
start = time.ticks_ms()
while not sta_if.isconnected():
if time.ticks_diff(time.ticks_ms(), start) > timeout * 1000:
print("Failed to connect within timeout")
return False
time.sleep(0.5)
print("Network config:", sta_if.ifconfig())
return True


# Create Inkplate object
inkplate = Inkplate()

# Initialize the display, needs to be called only once
inkplate.begin()

# Connect to WiFi
if not do_connect():
raise SystemExit("WiFi connection failed")

# Draw an image on the screen.
#
# Parameters:
# - path: File path to the image. Supports local paths (e.g., from SD card) or URLs.
# Supported formats: JPG, PNG, BMP.
#
# - x0: X-coordinate of the top-left corner where the image will be displayed.
#
# - y0: Y-coordinate of the top-left corner where the image will be displayed.
#
# - invert (bool, default=False): If True, inverts the image colors.
#
# - dither (bool, default=False): If True, applies a dithering algorithm to
# the image for better grayscale rendering.
#
# - kernel_type (int): Specifies the dithering algorithm to use.
# Available options:
# Inkplate.KERNEL_FLOYD_STEINBERG = 0
# Inkplate.KERNEL_JJN = 1
# Inkplate.KERNEL_STUCKI = 2
# Inkplate.KERNEL_BURKES = 3
#
# Performance Notes:
# - JPG: ~3 seconds (or ~14s with dithering)
# - PNG: ~9 seconds (or ~19s with dithering)
# - BMP: ~20 seconds (or ~40s with dithering)
# - Maximum image file size: ~800kB
#
# Example usage:
inkplate.draw_image(
"https://i.imgur.com/nSExTGr.jpeg", # URL to image
0,
0, # X, Y position
invert=False, # Do not invert colors
dither=True, # Enable dithering
kernel_type=Inkplate.KERNEL_FLOYD_STEINBERG, # Dithering algorithm
)

# Show the image from the internal buffer
inkplate.display()
Expected output on Inkplate display
Example image displayed on Inkplate with Dithering enabled
Expected output on Inkplate display
Example image displayed on Inkplate without Dithering

inkplate.draw_image()

This function draws an image from the specified char path (either web URL or local file path)

Returns type: none

Function parameters:

TypeNameDescription
stringpathPath and filename of the image. Can be a URL (for web images) or a file path (on the microSD card).
intx0X-coordinate of the image's upper-left corner in the framebuffer.
inty0Y-coordinate of the image's upper-left corner in the framebuffer.
boolinvertIf true, inverts colors.
boolditherDithering mode: 0 (disabled), 1 (enabled).
intkernel_typeSpecifies dithering algorithm to use.
ℹ️

Available options for dithering algorithm:

AlgorithmValue
Inkplate.KERNEL_FLOYD_STEINBERG0
Inkplate.KERNEL_JJN1
Inkplate.KERNEL_STUCKI2
Inkplate.KERNEL_BURKES3

Performance Notes

  • JPG: ~3 seconds (or ~14s with dithering)
  • PNG: ~9 seconds (or ~19s with dithering)
  • BMP: ~20 seconds (or ~40s with dithering)
  • Maximum image file size: ~800kB

Full example

display_image_web.py

Example showing how to connect to WiFi and render an image from a URL.