Last active
July 23, 2022 21:01
-
-
Save OmgCopito95/4b834b8da6bfb9965a95917ba6e2e980 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import sys | |
if sys.version_info < (3, 0): | |
from urllib2 import urlopen | |
else: | |
from urllib.request import urlopen | |
import io | |
from colorthief import ColorThief | |
import numpy as np | |
import matplotlib.pyplot as plt | |
# ------------------------------------------ # | |
#fd = urlopen('https://media.istockphoto.com/vectors/seamless-pattern-with-cute-dinosaur-stegosaurus-and-triceratops-in-vector-id1356147671?b=1&k=20&m=1356147671&s=170667a&w=0&h=zjCp-rIC-2i0Nc_N9Bj-i9ajjTYUBmC6fqihc1F5TfM=') | |
#f = io.BytesIO(fd.read()) | |
f = 'C:/Users/.../Desktop/2.jpg' | |
color_thief = ColorThief(f) | |
#print(color_thief.get_color(quality=1)) | |
#print(color_thief.get_palette(quality=1)) | |
palette = color_thief.get_palette(quality=1) | |
palette = np.array(palette)[np.newaxis, :, :5] | |
#palette = np.array(palette)[np.newaxis, :5, :5] | |
plt.imshow(palette) | |
plt.axis('off') | |
#plt.show() | |
#plt.savefig("paleta.png",bbox_inches='tight', pad_inches=0, transparent=True, dpi=30) | |
plt.savefig("paleta.png",bbox_inches='tight') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment