From 9ad5bc758036da7777250763a37693cf1fdedbc4 Mon Sep 17 00:00:00 2001 From: IParzivalDev Date: Mon, 22 Jan 2024 14:41:53 -0400 Subject: [PATCH] First Commit --- .gitignore | 1 + README.md | 49 ++++++++++++++++++++++++++ install.bat | 4 +++ install.sh | 4 +++ main.py | 87 +++++++++++++++++++++++++++++++++++++++++++++++ requirements.txt | 3 ++ run.bat | 2 ++ run.sh | 2 ++ skin.png | Bin 0 -> 1121 bytes 9 files changed, 152 insertions(+) create mode 100644 .gitignore create mode 100644 README.md create mode 100644 install.bat create mode 100755 install.sh create mode 100644 main.py create mode 100644 requirements.txt create mode 100644 run.bat create mode 100755 run.sh create mode 100644 skin.png diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8fa5b33 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +env \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..b43d4ee --- /dev/null +++ b/README.md @@ -0,0 +1,49 @@ +# Minecraft Skin Checker + +Verify that a minecraft skin in image format is valid. + +## Installation + +Install Minecraft Skin Checker + +First star my repository. +:) + +Assuming you have Python and Git installed. + +```bash + # Clone the repo + git clone https://github.com/IParzivalDev/Minecraft-Skin-Checker.git + + # Move to the repository directory + cd Minecraft-Skin-Checker + + # If you're on linux or darwin, run this command: + chmod +x install.sh && chmod +x run.sh + + # If you are on windows you just have to change to execution permissions to the files: run.bat and install.bat + + # Run the install.sh in a shell if you are on linux or darwin + ./install.sh + + # If you are on windows run install.bat + + # If you have an installation error, create an issue and I will be able to help you. + + # With this, you should already have the program installed :) + +``` + +## Using + +If you are on linux or darwin: + +```bash + ./run.sh +``` + +If you are on windows: + +```bash + ./run.bat +``` diff --git a/install.bat b/install.bat new file mode 100644 index 0000000..3c60d63 --- /dev/null +++ b/install.bat @@ -0,0 +1,4 @@ +python3 -m venv env +source ./env/bin/activate +pip install -r requirements.txt +echo "Minecraft Skin Checker installed successfuly. Now run: run.sh or run.bat." \ No newline at end of file diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..3c60d63 --- /dev/null +++ b/install.sh @@ -0,0 +1,4 @@ +python3 -m venv env +source ./env/bin/activate +pip install -r requirements.txt +echo "Minecraft Skin Checker installed successfuly. Now run: run.sh or run.bat." \ No newline at end of file diff --git a/main.py b/main.py new file mode 100644 index 0000000..81fa257 --- /dev/null +++ b/main.py @@ -0,0 +1,87 @@ +from PIL import Image +import numpy as np +import os +import platform +from colorama import Fore, Style + + +def verify_skin(skin: Image) -> bool: + if skin.size != (64, 64): + return False + + m = simplify_matrix(matrix(skin)) + + pixels = np.array(m) + + sects = [ + pixels[0:8, 8:24], + pixels[9:16, 0:32], + pixels[16:20, 20:28], + pixels[16:20, 44:50], + pixels[20:32, 0:54], + pixels[48:52, 36:42], + pixels[52:64, 16:46], + ] + + for sect in sects: + if np.all(sect != 1): + return False + + return True + + +def simplify_matrix(matrix: list) -> list: + new_matrix = [] + + for y in range(len(matrix)): + new_row = [] + for x in range(len(matrix[0])): + color = matrix[y][x] + + if color == (0, 0, 0, 0): + new_row.append(0) + else: + new_row.append(1) + new_matrix.append(new_row) + + return new_matrix + + +def matrix(img: Image) -> list: + width, height = img.size + + pixels = [] + + for y in range(height): + row = [] + for x in range(width): + r, g, b, a = img.getpixel((x, y)) + row.append((r, g, b, a)) + pixels.append(row) + + return pixels + + +def clear(): + if platform.system() == "Windows": + os.system("cls") + elif platform.system() == "Linux" or platform.system() == "Darwin": + os.system("clear") + + +if __name__ == "__main__": + clear() + try: + skin = Image.open(f"{input('Enter the skin path: ')}").convert("RGBA") + except: + print(f"{Fore.RED}This image could not be found.{Style.RESET_ALL}") + exit() + + if verify_skin(skin): + print( + f"{Fore.GREEN}This skin is valid or meets the minimum requirements.{Style.RESET_ALL}" + ) + else: + print( + f"{Fore.RED}This skin is invalid or does not meet the minimum requirements.{Style.RESET_ALL}" + ) diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..3ce483e --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +colorama==0.4.6 +numpy==1.26.3 +pillow==10.2.0 diff --git a/run.bat b/run.bat new file mode 100644 index 0000000..901e1ca --- /dev/null +++ b/run.bat @@ -0,0 +1,2 @@ +source ./env/bin/activate +python main.py \ No newline at end of file diff --git a/run.sh b/run.sh new file mode 100755 index 0000000..901e1ca --- /dev/null +++ b/run.sh @@ -0,0 +1,2 @@ +source ./env/bin/activate +python main.py \ No newline at end of file diff --git a/skin.png b/skin.png new file mode 100644 index 0000000000000000000000000000000000000000..f6782b317bea64c5d0b5b7fdf66a29ac7d9a11f2 GIT binary patch literal 1121 zcmV-n1fKheP)jkY8ww~J3n&~5C@3f?91JQQ4J#fED;^Fk9u6!X5iK1KEg%pt9}h1e4KE@Q zFeq{|BM>tr5i}(dIw%x6F^NAa6+b^eK_Lu69STA!5=9~oMmnWYF(pzcCQ?0#R!Pia zLoaGTFl%dTZ9^(=MJ#kkFLg&RdQLNdQ#657IfGR@gi{aeyd6vv6i-5rWtg=yQIu$&}eDVeKWp_?z&Ak)lMR`%xq z|2K5*9hZ37Z3BMg`|RN!#?EKw+?|JgGnuaD3I$z>wxWOlNlDwNR&|3ERxIOw zwYs5|h^q3rNCP0IX4F>9hmUK9Vbl!GBmm%Zkq9u0L|a{6&>npH_2bXaZ-%z8ysD9+ z$>$=uf^x-FOXm8;#m$G$;dQufmQ=G+R{30{XhB_^KRVkCZ+CCL?%rN+o*m6E!bv_C zDFEf-+F@|~>gu=SeE;(PI5=D@mKlJ}Me-h~mA%W3=eAyNpPX#HedBta%e{(f^0`O^ zc%Aci=O0h^Umk34KiYc!V*fNa_d1^ExpXdEFV!qO1>FPj@A+t!@^`!9=W#xdn@-b7 z21Ne}BY-?;DgacFhy3PLEsOwcd&%Ab!D828&4FaO)w*iQC<`&hih?ng>3OU~s{)Dv zM5`o8Z~+ixjB^lE0Eor1f)!Y$c!1plzy%n|kVr3%@>!hYp#K80l9YwtkqjR+#tMQX z0>C+W6ac+*Kpm6?Aw*LUf)J`fj1dHZAA)=c=-LN>JJ;(yfCNcV3PKQPp&J?kz=ya+i?K9_Y^pQ^~(T?;xj-P@>co)_5gq;A%*4eooAw@ zGk`w?Xf!yW(Rc=m0JH>zaygg-S^~sDw|4-rR{8)@B41%s0YGPRXJ?7FS4RlLCbK)Y z(*Pg|MfrSV*;m>->|Hwuh5$3oG}BDu_ywUaNNqSozF>?B;(ft5Eu;p-`Gr_tkPKMr zy=Y>6K_bBZ2Z;3r;{alPfefqaLSK-!1)(oU21Kn0eSsKY4*>+eK%`;6 nAoK-dz~Jj%=nGN<5`4j5+FtCj?o4(y00000NkvXXu0mjf@E^(S literal 0 HcmV?d00001