-
Notifications
You must be signed in to change notification settings - Fork 0
/
matrix.py
36 lines (24 loc) · 916 Bytes
/
matrix.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import os,time,sys,urllib.request
from PIL import Image
def displayCover(matrix,coverURL=None):
#display album cover if given an image
if coverURL is not None:
#get image from url
urllib.request.urlretrieve(
coverURL,
'cover.jpg'
)
#open and format image from url
image = Image.open('cover.jpg')
image = image.rotate(90)
image = image.resize((64,64))
image.thumbnail((matrix.width,matrix.height),Image.ANTIALIAS)
matrix.SetImage(image.convert('RGB'))
#display default image if not given an image
if coverURL is None:
#open and format image from url
image = Image.open('cover.jpg')
image = image.rotate(90)
image = image.resize((64,64))
image.thumbnail((matrix.width,matrix.height),Image.ANTIALIAS)
matrix.SetImage(image.convert('RGB'))