I am trying to crop an image using PIL.image.crop() and then determine the most dominant color in the cropped image. I've tried using ColorThief but it will only analyze an image if a path to the image is specified, and I don't want to have to save a file to my device every time I run the program. Is there a way to find the dominant color without saving the cropped image to my device?
# -*- coding: utf-8 -*-
"""
Created on Wed Sep 14 11:39:07 2022
@author: nickr
"""
from PIL import Image
from colorthief import ColorThief
im = Image.open("C:/Users/nickr/Desktop/right.png")
im1 = im.crop((0, 0, 50, 50)) #gives top left grid cell
im1.show()
color_thief = ColorThief(im1) #this will not work because it is not a path
im1Color = color_thief.get_color(quality=1)
print(im1Color)