Remove Numpy dependencie (aarch64 ready)

master
kirbylife 2021-05-19 14:19:08 -05:00
parent 6334fa7e98
commit e0c92e08c0
3 changed files with 12 additions and 13 deletions

View File

@ -5,7 +5,7 @@ sdkpath:=$(HOME)/SailfishOS
sourcePath:=$(shell pwd)
dependencies=$(shell for file in `cat dependencies.txt`;do echo "-d "$${file};done;)
arch:=armv7hl
version:=0.4.0
version:=0.5.0
iteration:=1
rpmname:=$(Appname)-$(version)-$(iteration).$(arch).rpm
ssh_user:=defaultuser

View File

@ -1,5 +1,4 @@
libsailfishapp-launcher
pyotherside-qml-plugin-python3-qt5
python3-base
python3-numpy
python3-pillow
python3-imaging

View File

@ -2,7 +2,7 @@ import pyotherside
from PIL import Image, ImageOps, ImageDraw, ImageChops
from io import BytesIO
from glob import glob
import numpy as np
from collections import Counter
import base64
import os
import shutil
@ -14,16 +14,16 @@ def base64_to_img(base64_bytes: bytes) -> Image:
img = img.convert("RGBA")
return img
def img_to_array(img: Image) -> np.array:
img_array = np.array(img)
return img_array
def avg_colors(img):
img_array = img_to_array(img)
colors, count = np.unique(img_array.reshape(-1,img_array.shape[-1]), axis=0, return_counts=True)
return tuple(colors[count.argmax()])
counter = Counter()
width, height = img.size
for x in range(width):
for y in range(height):
pixel = img.getpixel((x, y))
if pixel[-1] > 0: # Doesn't count the transparent pixels
counter[pixel] += 1
print(counter.most_common(4))
return counter.most_common(1)[0][0]
def add_background(img: Image, bg_tuple: tuple) -> Image:
bg = Image.new("RGBA", img.size, bg_tuple)