Inky Impression help needed - slideshow?

I’m a bit new to python but I was able to get the Inky Impression working with my raspberry PI 3+ but I have a few questions if anyone has time. I was able to swap the rotation to Portrait so I can display images in that orientation and dimensions. Now I would just like to have a simple script running that will cycle through the 20 or so jpegs I have and display them once every hour or something like that.

I have tried several code samples out there but several different folks but just cannot get anything to work as I want. This seems kinda simple, does anyone have something close?

Better late than never…

I’m a python novice also, but I’ve managed to get a script that randomly selects an image from a directory with the following lines:

#!/usr/bin/env python3

import os
import random
from PIL import Image

# Path to the directory containing images
image_directory = "/home/pi/photos"

# Get a list of all image files in the directory
image_files = [f for f in os.listdir(image_directory) if f.endswith(('.png', '.jpg', '.jpeg'))]

# Check if there are any images
if not image_files:
    print("No images found in the specified directory.")
else:
    # Randomly select an image
    selected_image = random.choice(image_files)
    image_path = os.path.join(image_directory, selected_image)

    # Load the image
    img = Image.open(image_path)

    # etc etc etc

    # Display the image
    inky.set_image(img)
    inky.show()

    print(f"Displayed image: {selected_image}")

Then I have a cron job that runs the script every 10 minutes.

Could I ask about your portrait rotation? I have both landscape and portrait photos. My script re-sizes them to fit the display:

img = img.resize(inky.resolution)

but that looks awful for portrait photos, of course.

Any advice?