updating extraction scripts

This commit is contained in:
2021-03-21 00:11:52 +00:00
parent a399ca0e2b
commit 463d20999f
9 changed files with 266 additions and 53 deletions

View File

@@ -1,10 +1,8 @@
import glob
import numpy
from PIL import Image, ImageDraw
def extract_image(filename: str, output_path: str) -> None:
def extract_image(filename: str, output_path: str, shikigami_name: str) -> None:
"""
Extract a spell card from a screenshot from a device. Mask is valid for 1304x603
screenshot from an iPhone 12 Pro.
@@ -59,18 +57,11 @@ def extract_image(filename: str, output_path: str) -> None:
# convert back to an image
extracted_image = Image.fromarray(extracted_image_array, "RGBA")
# crop
extracted_image = extracted_image.crop((496, 59, 788, 567))
# save the image
extracted_image.save(f"{output_path}/{filename.split('/')[-1].split('.')[-2]}.png")
if __name__ == "__main__":
for image in glob.glob(
"/Users/dtomlinson/git-repos/web-dev/onmyoji-deck-builder/."
"image-extraction/images/spells/in/*.jpeg"
):
print(image)
extract_image(
image,
"/Users/dtomlinson/git-repos/web-dev/onmyoji-deck-builder/."
"image-extraction/images/spells/out",
)
extracted_image.save(
f"{output_path}/{shikigami_name}-"
f"{filename.split('/')[-1].split('.')[-2]}.png"
)