• Skip to content

Main Menu

  • Home
  • Paintings
  • Interactive Work
  • About
  • Posts
  • Back
  • NM Women Series
  • Hollyhocks Series
  • Daily Paintings
  • Small Works
  • Back
  • Games and Toys
  • Ribbons
  • ORBS
Enrico Trujillo

Main Menu

  • Home
  • Paintings
    • NM Women Series
    • Hollyhocks Series
    • Daily Paintings
    • Small Works
  • Interactive Work
    • Games and Toys
    • Ribbons
    • ORBS
  • About
  • Posts
  • Search

MagTag Online Image

 Posted on on March 15, 2023

Here is a bit of code that pulls a random image from the internet and displays it on a MagTag screen.

import board
import displayio
import adafruit_imageload
import adafruit_requests as requests
import adafruit_magtag.magtag as magtag
from adafruit_display_text import label
from adafruit_bitmap_font import bitmap_font
from adafruit_imageload import dither


# Set up the MagTag display and buttons
magtag = magtag.MagTag()

# Get the image from picsum.photos
image_url = "https://picsum.photos/g/296/128"
response = requests.get(image_url)
image_file = response.content
image, palette = adafruit_imageload.load(image_file, bitmap=displayio.Bitmap, palette=displayio.Palette)

# Dither the image
dither.dither_bitmask(image, bitmap=displayio.Bitmap)

# Create a new display group and show the image on the screen
group = displayio.Group()
tile_grid = displayio.TileGrid(image, pixel_shader=palette)
group.append(tile_grid)
magtag.display.show(group)

# Wait for button press to exit
while not magtag.peripherals.button_a:
    pass

Posted in Uncategorized

Comments are closed.

Post navigation

Previous
Next

Primary

Recent Posts

  • Building an Art Store with WooCommerce: A Guide for Solo Artists
  • Egon Schiele⁣⁣ Portrait of the Painter Anton Peschka⁣⁣ 1909
  • Learning to Stretch My Paintings a Little Further
  • Growing Your Artist Footprint Online—Simple Steps I’m Taking (and You Can Too)
  • Choosing My Canvas: Why Format Matters When Painting People and Places

Archives

  • April 2025
  • March 2025
  • February 2025
  • January 2025
  • December 2024
  • November 2024
  • October 2024
  • August 2024
  • July 2024
  • April 2024
  • March 2024
  • December 2023
  • November 2023
  • October 2023
  • September 2023
  • August 2023
  • July 2023
  • June 2023
  • May 2023
  • April 2023
  • March 2023
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • July 2022
  • March 2022
  • February 2022
  • December 2021
  • October 2021
  • August 2021

Categories

  • Advice
  • Agriculture
  • Art
  • Article
  • Business
  • Community
  • Culture
  • Daily
  • Drawing
  • Galleries
  • Home
  • Illustration
  • Land
  • News
  • Painting
  • Photography
  • Planning
  • Tech
  • Uncategorized

Follow us

Follow us on TwitterLike us on FacebookSubscribe to our Channel on YouTubeFollow us on GithubFollow us on InstagramFollow us on CodepenFollow us on SoundCloud

© Enrico Trujillo 2025MINIMAL

x