Skip to content

Commit

Permalink
change: Add lost trims and optimize transformer
Browse files Browse the repository at this point in the history
  • Loading branch information
7777777-4547 committed Jun 18, 2024
1 parent 34bbf78 commit aea635b
Show file tree
Hide file tree
Showing 19 changed files with 31 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/transform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ jobs:
uses: Andro999b/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
message: 'change: transform default to labPBR'
message: 'change: Transform default to labPBR'
branch: ${{ github.ref_name }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#vscode
.vscode/
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 28 additions & 1 deletion transformer.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,29 @@
from PIL import Image
import os
import shutil
import hashlib


class transformerLogger:

@staticmethod
def Logger(char):
print(char)


@staticmethod
def transformFile(rawName, newName):
print(f" \033[34m|\033[0m {rawName} \033[34m->\033[0m {newName}")

def calculateFileHash(filePath: str):

hashObj = hashlib.new("sha256")

with open(filePath, 'rb') as file:
for chunk in iter(lambda: file.read(4096), b''):
hashObj.update(chunk)

return hashObj.hexdigest()


def transformLightToAlpna(image: Image.Image):

Expand Down Expand Up @@ -102,10 +115,20 @@ def main(path: str, entityMode = False):

if height//width != 1 and entityMode == False:
invertedImage = transformLightToAlpnaGlobally(image)

if os.path.exists(newFile):
if invertedImage.tobytes() == Image.open(newFile).tobytes():
continue

invertedImage.save(newFile)

else:
invertedImage = transformLightToAlpna(image)

if os.path.exists(newFile):
if invertedImage.tobytes() == Image.open(newFile).tobytes():
continue

invertedImage.save(newFile)

transformerLogger.transformFile(fileName, fileName.replace(rawSuffix, newSuffix))
Expand All @@ -116,6 +139,10 @@ def main(path: str, entityMode = False):
newFile = rawFile.replace(f"{rawSuffix}.mcmeta", f"{newSuffix}.mcmeta")

if os.path.exists(newFile):

if calculateFileHash(rawFile) == calculateFileHash(newFile):
continue

os.remove(newFile)

shutil.copy2(rawFile, newFile)
Expand Down

0 comments on commit aea635b

Please sign in to comment.