Remove Numpy dependencie (aarch64 ready)
parent
6334fa7e98
commit
e0c92e08c0
2
Makefile
2
Makefile
|
@ -5,7 +5,7 @@ sdkpath:=$(HOME)/SailfishOS
|
||||||
sourcePath:=$(shell pwd)
|
sourcePath:=$(shell pwd)
|
||||||
dependencies=$(shell for file in `cat dependencies.txt`;do echo "-d "$${file};done;)
|
dependencies=$(shell for file in `cat dependencies.txt`;do echo "-d "$${file};done;)
|
||||||
arch:=armv7hl
|
arch:=armv7hl
|
||||||
version:=0.4.0
|
version:=0.5.0
|
||||||
iteration:=1
|
iteration:=1
|
||||||
rpmname:=$(Appname)-$(version)-$(iteration).$(arch).rpm
|
rpmname:=$(Appname)-$(version)-$(iteration).$(arch).rpm
|
||||||
ssh_user:=defaultuser
|
ssh_user:=defaultuser
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
libsailfishapp-launcher
|
libsailfishapp-launcher
|
||||||
pyotherside-qml-plugin-python3-qt5
|
pyotherside-qml-plugin-python3-qt5
|
||||||
python3-base
|
python3-base
|
||||||
python3-numpy
|
python3-imaging
|
||||||
python3-pillow
|
|
||||||
|
|
20
src/main.py
20
src/main.py
|
@ -2,7 +2,7 @@ import pyotherside
|
||||||
from PIL import Image, ImageOps, ImageDraw, ImageChops
|
from PIL import Image, ImageOps, ImageDraw, ImageChops
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
from glob import glob
|
from glob import glob
|
||||||
import numpy as np
|
from collections import Counter
|
||||||
import base64
|
import base64
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
|
@ -14,16 +14,16 @@ def base64_to_img(base64_bytes: bytes) -> Image:
|
||||||
img = img.convert("RGBA")
|
img = img.convert("RGBA")
|
||||||
return img
|
return img
|
||||||
|
|
||||||
def img_to_array(img: Image) -> np.array:
|
|
||||||
img_array = np.array(img)
|
|
||||||
return img_array
|
|
||||||
|
|
||||||
def avg_colors(img):
|
def avg_colors(img):
|
||||||
img_array = img_to_array(img)
|
counter = Counter()
|
||||||
colors, count = np.unique(img_array.reshape(-1,img_array.shape[-1]), axis=0, return_counts=True)
|
width, height = img.size
|
||||||
|
for x in range(width):
|
||||||
return tuple(colors[count.argmax()])
|
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:
|
def add_background(img: Image, bg_tuple: tuple) -> Image:
|
||||||
bg = Image.new("RGBA", img.size, bg_tuple)
|
bg = Image.new("RGBA", img.size, bg_tuple)
|
||||||
|
|
Loading…
Reference in New Issue