updating extraction scripts
This commit is contained in:
@@ -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 form card from a screenshot from a device. Screenshot for each card
|
||||
taken from the Hyakabun scrollery. Image will be resized and the card extracted.
|
||||
@@ -65,18 +63,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((495, 39, 789, 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/forms/in/*.*"
|
||||
):
|
||||
print(image)
|
||||
extract_image(
|
||||
image,
|
||||
"/Users/dtomlinson/git-repos/web-dev/onmyoji-deck-builder/."
|
||||
"image-extraction/images/forms/out",
|
||||
)
|
||||
extracted_image.save(
|
||||
f"{output_path}/{shikigami_name}-"
|
||||
f"{filename.split('/')[-1].split('.')[-2]}.png"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user