Skip to content

Commit

Permalink
First Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
IParzivalDev committed Jan 22, 2024
0 parents commit 9ad5bc7
Show file tree
Hide file tree
Showing 9 changed files with 152 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
env
49 changes: 49 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
```
4 changes: 4 additions & 0 deletions install.bat
Original file line number Diff line number Diff line change
@@ -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."
4 changes: 4 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -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."
87 changes: 87 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
@@ -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}"
)
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
colorama==0.4.6
numpy==1.26.3
pillow==10.2.0
2 changes: 2 additions & 0 deletions run.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
source ./env/bin/activate
python main.py
2 changes: 2 additions & 0 deletions run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
source ./env/bin/activate
python main.py
Binary file added skin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 9ad5bc7

Please sign in to comment.