Initial commit: IYmtg Master project

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-24 09:12:46 -05:00
commit b993ef4020
16 changed files with 3303 additions and 0 deletions

View File

@@ -0,0 +1,91 @@
# INSTALL: pip install requests pillow
import os, requests, time, concurrent.futures
from PIL import Image
from io import BytesIO
HEADERS = { 'User-Agent': 'IYmtg/1.0 (contact@yourdomain.com)', 'Accept': 'application/json' }
OUTPUT_DIR = "Set_Symbol_Training"
def main():
if not os.path.exists(OUTPUT_DIR): os.makedirs(OUTPUT_DIR)
print("--- IYmtg Symbol Harvester ---")
session = requests.Session()
session.headers.update(HEADERS)
try:
response = session.get("https://api.scryfall.com/sets", timeout=15)
response.raise_for_status()
all_sets = response.json().get('data', [])
except Exception as e:
print(f"Error fetching sets: {e}")
return
valid_types = ['core', 'expansion', 'masters', 'draft_innovation']
target_sets = [s for s in all_sets if s.get('set_type') in valid_types]
print(f"Found {len(target_sets)} valid sets.")
# OPTIMIZATION: Process sets in parallel to speed up dataset creation
with concurrent.futures.ThreadPoolExecutor(max_workers=5) as executor:
executor.map(lambda s: process_set(s, session), target_sets)
print("DONE. Drag 'Set_Symbol_Training' into Create ML -> Image Classification.")
def process_set(set_obj, session):
set_code = set_obj['code']
print(f"Processing {set_code}...")
set_dir = os.path.join(OUTPUT_DIR, set_code.upper())
os.makedirs(set_dir, exist_ok=True)
try:
url = f"https://api.scryfall.com/cards/search?q=set:{set_code}+unique:prints&per_page=5"
resp = session.get(url, timeout=10)
if resp.status_code != 200:
print(f"Skipping {set_code}: HTTP {resp.status_code}")
return
cards_resp = resp.json()
for i, card in enumerate(cards_resp.get('data', [])):
image_url = None
uris = {}
if 'image_uris' in card:
uris = card['image_uris']
elif 'card_faces' in card and len(card['card_faces']) > 0 and 'image_uris' in card['card_faces'][0]:
uris = card['card_faces'][0]['image_uris']
if 'large' in uris: image_url = uris['large']
elif 'normal' in uris: image_url = uris['normal']
if image_url:
try:
img_resp = session.get(image_url, timeout=10)
if img_resp.status_code != 200: continue
try:
img = Image.open(BytesIO(img_resp.content))
img.verify() # Verify integrity
img = Image.open(BytesIO(img_resp.content)) # Re-open after verify
except Exception:
print(f"Skipping corrupt image in {set_code}")
continue
width, height = img.size
# WARNING: This crop area is tuned for modern card frames (M15+).
# Older sets or special frames (Planeswalkers, Sagas) may require different coordinates.
crop_area = (width * 0.85, height * 0.58, width * 0.95, height * 0.65)
symbol = img.crop(crop_area)
symbol = symbol.convert("RGB")
symbol.save(os.path.join(set_dir, f"sample_{i}.jpg"))
except Exception as e:
print(f"Error downloading image for {set_code}: {e}")
except Exception as e:
print(f"Error searching cards for {set_code}: {e}")
if __name__ == "__main__": main()

View File

@@ -0,0 +1,58 @@
import os
import sys
try:
from PIL import Image, ImageDraw
except ImportError:
print("❌ Error: Pillow library not found.")
print("👉 Please run: pip install Pillow")
sys.exit(1)
# Configuration
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
RAW_DIR = os.path.join(BASE_DIR, "Raw_Assets")
# Assets to generate (Keys match resize_assets.py)
ASSETS = [
"AppIcon",
"logo_header",
"scanner_frame",
"empty_library",
"share_watermark",
"card_placeholder"
]
def create_placeholders():
if not os.path.exists(RAW_DIR):
os.makedirs(RAW_DIR)
print(f"✅ Created folder: {RAW_DIR}")
print(f"🚀 Generating placeholder images in 'Raw_Assets'...")
for name in ASSETS:
# Generate a generic large square for the raw input
# The resize script handles cropping, so we just need a valid image source
# We use 2048x2048 to simulate a large AI output
img = Image.new('RGB', (2048, 2048), color=(40, 40, 50))
d = ImageDraw.Draw(img)
# Draw a border and text
d.rectangle([50, 50, 1998, 1998], outline=(0, 255, 0), width=40)
# Simple text drawing (default font)
# In a real scenario, you'd replace these with your AI images
d.text((100, 100), f"PLACEHOLDER: {name}", fill=(0, 255, 0))
d.text((100, 200), "Replace with AI Art", fill=(255, 255, 255))
filename = f"{name}.png"
path = os.path.join(RAW_DIR, filename)
# Only create if it doesn't exist to avoid overwriting real AI art
if not os.path.exists(path):
img.save(path)
print(f"✅ Created: {filename}")
else:
print(f"⚠️ Skipped: {filename} (File already exists)")
if __name__ == "__main__":
create_placeholders()

View File

@@ -0,0 +1,69 @@
import os
import sys
# Dependency Check
try:
from PIL import Image, ImageOps
except ImportError:
print("❌ Error: Pillow library not found.")
print("👉 Please run: pip install Pillow")
sys.exit(1)
# Configuration
# Paths are relative to where the script is run, assuming run from root or automation folder
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
SOURCE_DIR = os.path.join(BASE_DIR, "Raw_Assets")
OUTPUT_DIR = os.path.join(BASE_DIR, "Ready_Assets")
# Target Dimensions (Width, Height)
ASSETS = {
"AppIcon": (1024, 1024),
"logo_header": (300, 80),
"scanner_frame": (600, 800),
"empty_library": (800, 800),
"share_watermark": (400, 100),
"card_placeholder": (600, 840)
}
def process_assets():
print(f"📂 Working Directory: {BASE_DIR}")
# Create directories if they don't exist
if not os.path.exists(SOURCE_DIR):
os.makedirs(SOURCE_DIR)
print(f"✅ Created source folder: {SOURCE_DIR}")
print("👉 ACTION REQUIRED: Place your raw AI images here (e.g., 'AppIcon.png') and run this script again.")
return
if not os.path.exists(OUTPUT_DIR):
os.makedirs(OUTPUT_DIR)
print(f"✅ Created output folder: {OUTPUT_DIR}")
print(f"🚀 Processing images from 'Raw_Assets'...")
for name, size in ASSETS.items():
found = False
# Check for common image extensions
for ext in [".png", ".jpg", ".jpeg", ".webp"]:
source_path = os.path.join(SOURCE_DIR, name + ext)
if os.path.exists(source_path):
try:
img = Image.open(source_path)
if img.mode != 'RGBA': img = img.convert('RGBA')
# Smart Crop & Resize (Center focus)
processed_img = ImageOps.fit(img, size, method=Image.Resampling.LANCZOS)
output_path = os.path.join(OUTPUT_DIR, name + ".png")
processed_img.save(output_path, "PNG")
print(f"✅ Generated: {name}.png ({size[0]}x{size[1]})")
found = True
break
except Exception as e:
print(f"❌ Error processing {name}: {e}")
if not found:
print(f"⚠️ Skipped: {name} (File not found in Raw_Assets)")
if __name__ == "__main__":
process_assets()

View File

@@ -0,0 +1,13 @@
#!/bin/bash
echo "--- Starting IYmtg Update ---"
cd ../IYmtg_Builder_Mac
xcodebuild -scheme IYmtg_Builder_Mac -configuration Release
./Build/Products/Release/IYmtg_Builder_Mac
mv ~/IYmtg_Workspace/cards.json ../IYmtg_App_iOS/cards.json
# Generate Description Update
echo "Generating Model Report..."
cd ../IYmtg_Automation
python3 generate_report.py
echo "SUCCESS. Deploy App Now."