Compare commits
11 Commits
2701dfbf85
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 13bba33c26 | |||
| ecd98c72ce | |||
|
|
9a28daa2cd | ||
|
|
ebf8bc72aa | ||
|
|
2ef510358d | ||
|
|
d492905e57 | ||
|
|
7a4d122976 | ||
|
|
8cc5138888 | ||
| 3f47b3cda4 | |||
|
|
c1045b4878 | ||
|
|
70c14acaa5 |
70
KeyGenerator/A4 Printable Grid.py
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
import os
|
||||||
|
from PIL import Image
|
||||||
|
|
||||||
|
# --- CONFIGURATION ---
|
||||||
|
CARD_DIR = os.path.join(os.getcwd(),'keychain_cards')
|
||||||
|
OUTPUT_PDF = os.path.join(os.getcwd(), 'keychain_3x3_perfect.pdf')
|
||||||
|
|
||||||
|
# A4 at 300 DPI
|
||||||
|
PAGE_W, PAGE_H = 2480, 3508
|
||||||
|
COLS, ROWS = 3, 3 # 9 cards per page
|
||||||
|
PAGE_MARGIN = 150
|
||||||
|
|
||||||
|
def generate_printable_pdf():
|
||||||
|
all_files = [f for f in os.listdir(CARD_DIR) if f.endswith('.png')]
|
||||||
|
if not all_files:
|
||||||
|
print("❌ No cards found.")
|
||||||
|
return
|
||||||
|
|
||||||
|
all_files.sort()
|
||||||
|
|
||||||
|
# Calculate slot size
|
||||||
|
available_w = PAGE_W - (PAGE_MARGIN * 2)
|
||||||
|
available_h = PAGE_H - (PAGE_MARGIN * 2)
|
||||||
|
slot_w = available_w // COLS
|
||||||
|
slot_h = available_h // ROWS
|
||||||
|
|
||||||
|
# TARGET CALCULATION (Maintain 300:450 ratio)
|
||||||
|
# We fit to the width of the slot and let height follow
|
||||||
|
target_w = int(slot_w * 0.9)
|
||||||
|
target_h = int(target_w * (450 / 300)) # Maintain original 1:1.5 ratio
|
||||||
|
|
||||||
|
# Safety check: if height is too big for slot, scale down based on height instead
|
||||||
|
if target_h > (slot_h * 0.9):
|
||||||
|
target_h = int(slot_h * 0.9)
|
||||||
|
target_w = int(target_h * (300 / 450))
|
||||||
|
|
||||||
|
pages = []
|
||||||
|
current_page = Image.new('RGB', (PAGE_W, PAGE_H), 'white')
|
||||||
|
|
||||||
|
print(f"📄 Generating {COLS}x{ROWS} grid. {len(all_files)} cards total.")
|
||||||
|
|
||||||
|
for i, filename in enumerate(all_files):
|
||||||
|
item_idx = i % (COLS * ROWS)
|
||||||
|
|
||||||
|
# New page logic
|
||||||
|
if item_idx == 0 and i > 0:
|
||||||
|
pages.append(current_page)
|
||||||
|
current_page = Image.new('RGB', (PAGE_W, PAGE_H), 'white')
|
||||||
|
|
||||||
|
row = item_idx // COLS
|
||||||
|
col = item_idx % COLS
|
||||||
|
|
||||||
|
img_path = os.path.join(CARD_DIR, filename)
|
||||||
|
card_img = Image.open(img_path).convert('RGB')
|
||||||
|
|
||||||
|
# Resize using the aspect-ratio-safe dimensions
|
||||||
|
card_img = card_img.resize((target_w, target_h), Image.Resampling.LANCZOS)
|
||||||
|
|
||||||
|
# Center in slot
|
||||||
|
x = PAGE_MARGIN + (col * slot_w) + (slot_w - target_w) // 2
|
||||||
|
y = PAGE_MARGIN + (row * slot_h) + (slot_h - target_h) // 2
|
||||||
|
|
||||||
|
current_page.paste(card_img, (x, y))
|
||||||
|
|
||||||
|
pages.append(current_page)
|
||||||
|
pages[0].save(OUTPUT_PDF, save_all=True, append_images=pages[1:], resolution=300.0, quality=100)
|
||||||
|
print(f"✅ Created {OUTPUT_PDF}. Now go print it and stop crying.")
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
generate_printable_pdf()
|
||||||
@@ -2,7 +2,7 @@ import pandas as pd
|
|||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
|
|
||||||
file_path = r'C:\Users\Pepitho\Desktop\SekiPOS\KeyGenerator\wea.xlsx'
|
file_path = os.path.join(os.getcwd(), 'PLU+FSMA+list+v1.0.xlsx')
|
||||||
sheet_name = 'Non FTL'
|
sheet_name = 'Non FTL'
|
||||||
new_url_base = "https://server-ifps.accurateig.com/assets/commodities/"
|
new_url_base = "https://server-ifps.accurateig.com/assets/commodities/"
|
||||||
|
|
||||||
|
|||||||
@@ -11,9 +11,9 @@ from io import BytesIO
|
|||||||
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
|
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
|
||||||
|
|
||||||
# --- CONFIGURATION ---
|
# --- CONFIGURATION ---
|
||||||
JSON_FILE = 'frutas.json'
|
JSON_FILE = os.path.join(os.getcwd(), 'frutas.json')
|
||||||
OUTPUT_DIR = 'keychain_cards'
|
OUTPUT_DIR = os.path.join(os.getcwd(), 'keychain_cards')
|
||||||
IMG_CACHE_DIR = 'image_cache'
|
IMG_CACHE_DIR = os.path.join(os.getcwd(), 'image_cache')
|
||||||
os.makedirs(OUTPUT_DIR, exist_ok=True)
|
os.makedirs(OUTPUT_DIR, exist_ok=True)
|
||||||
os.makedirs(IMG_CACHE_DIR, exist_ok=True)
|
os.makedirs(IMG_CACHE_DIR, exist_ok=True)
|
||||||
|
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 717 KiB After Width: | Height: | Size: 717 KiB |
|
Before Width: | Height: | Size: 2.0 MiB After Width: | Height: | Size: 2.0 MiB |
|
Before Width: | Height: | Size: 1.7 MiB After Width: | Height: | Size: 1.7 MiB |
|
Before Width: | Height: | Size: 2.3 MiB After Width: | Height: | Size: 2.3 MiB |
|
Before Width: | Height: | Size: 207 KiB After Width: | Height: | Size: 207 KiB |
|
Before Width: | Height: | Size: 2.5 MiB After Width: | Height: | Size: 2.5 MiB |
|
Before Width: | Height: | Size: 3.4 MiB After Width: | Height: | Size: 3.4 MiB |
|
Before Width: | Height: | Size: 3.5 MiB After Width: | Height: | Size: 3.5 MiB |
|
Before Width: | Height: | Size: 819 KiB After Width: | Height: | Size: 819 KiB |
|
Before Width: | Height: | Size: 879 KiB After Width: | Height: | Size: 879 KiB |
|
Before Width: | Height: | Size: 216 KiB After Width: | Height: | Size: 216 KiB |
|
Before Width: | Height: | Size: 2.7 MiB After Width: | Height: | Size: 2.7 MiB |
|
Before Width: | Height: | Size: 213 KiB After Width: | Height: | Size: 213 KiB |
|
Before Width: | Height: | Size: 3.0 MiB After Width: | Height: | Size: 3.0 MiB |
|
Before Width: | Height: | Size: 1.9 MiB After Width: | Height: | Size: 1.9 MiB |
|
Before Width: | Height: | Size: 118 KiB After Width: | Height: | Size: 118 KiB |
|
Before Width: | Height: | Size: 2.5 MiB After Width: | Height: | Size: 2.5 MiB |
|
Before Width: | Height: | Size: 1.4 MiB After Width: | Height: | Size: 1.4 MiB |
|
Before Width: | Height: | Size: 40 KiB After Width: | Height: | Size: 40 KiB |
|
Before Width: | Height: | Size: 578 KiB After Width: | Height: | Size: 578 KiB |
|
Before Width: | Height: | Size: 48 KiB After Width: | Height: | Size: 48 KiB |
|
Before Width: | Height: | Size: 1.9 MiB After Width: | Height: | Size: 1.9 MiB |
|
Before Width: | Height: | Size: 83 KiB After Width: | Height: | Size: 83 KiB |
|
Before Width: | Height: | Size: 188 KiB After Width: | Height: | Size: 188 KiB |
|
Before Width: | Height: | Size: 76 KiB After Width: | Height: | Size: 76 KiB |
|
Before Width: | Height: | Size: 2.3 MiB After Width: | Height: | Size: 2.3 MiB |
|
Before Width: | Height: | Size: 1.1 MiB After Width: | Height: | Size: 1.1 MiB |
|
Before Width: | Height: | Size: 1.4 MiB After Width: | Height: | Size: 1.4 MiB |
|
Before Width: | Height: | Size: 651 KiB After Width: | Height: | Size: 651 KiB |
|
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 19 KiB |
|
Before Width: | Height: | Size: 444 KiB After Width: | Height: | Size: 444 KiB |
|
Before Width: | Height: | Size: 1.2 MiB After Width: | Height: | Size: 1.2 MiB |
|
Before Width: | Height: | Size: 72 KiB After Width: | Height: | Size: 72 KiB |
|
Before Width: | Height: | Size: 814 KiB After Width: | Height: | Size: 814 KiB |
|
Before Width: | Height: | Size: 1.0 MiB After Width: | Height: | Size: 1.0 MiB |
|
Before Width: | Height: | Size: 2.4 MiB After Width: | Height: | Size: 2.4 MiB |
|
Before Width: | Height: | Size: 786 KiB After Width: | Height: | Size: 786 KiB |
|
Before Width: | Height: | Size: 730 KiB After Width: | Height: | Size: 730 KiB |
|
Before Width: | Height: | Size: 1.9 MiB After Width: | Height: | Size: 1.9 MiB |
|
Before Width: | Height: | Size: 636 KiB After Width: | Height: | Size: 636 KiB |
|
Before Width: | Height: | Size: 2.5 MiB After Width: | Height: | Size: 2.5 MiB |
|
Before Width: | Height: | Size: 1.4 MiB After Width: | Height: | Size: 1.4 MiB |
|
Before Width: | Height: | Size: 438 KiB After Width: | Height: | Size: 438 KiB |
|
Before Width: | Height: | Size: 1.8 MiB After Width: | Height: | Size: 1.8 MiB |
|
Before Width: | Height: | Size: 1.4 MiB After Width: | Height: | Size: 1.4 MiB |
|
Before Width: | Height: | Size: 2.0 MiB After Width: | Height: | Size: 2.0 MiB |
|
Before Width: | Height: | Size: 9.2 MiB After Width: | Height: | Size: 9.2 MiB |
|
Before Width: | Height: | Size: 2.0 MiB After Width: | Height: | Size: 2.0 MiB |
|
Before Width: | Height: | Size: 213 KiB After Width: | Height: | Size: 213 KiB |
|
Before Width: | Height: | Size: 2.1 MiB After Width: | Height: | Size: 2.1 MiB |
|
Before Width: | Height: | Size: 280 KiB After Width: | Height: | Size: 280 KiB |
|
Before Width: | Height: | Size: 464 KiB After Width: | Height: | Size: 464 KiB |
|
Before Width: | Height: | Size: 2.8 MiB After Width: | Height: | Size: 2.8 MiB |
|
Before Width: | Height: | Size: 148 KiB After Width: | Height: | Size: 148 KiB |
|
Before Width: | Height: | Size: 2.6 MiB After Width: | Height: | Size: 2.6 MiB |
|
Before Width: | Height: | Size: 1.0 MiB After Width: | Height: | Size: 1.0 MiB |
|
Before Width: | Height: | Size: 2.1 MiB After Width: | Height: | Size: 2.1 MiB |
|
Before Width: | Height: | Size: 2.9 MiB After Width: | Height: | Size: 2.9 MiB |
|
Before Width: | Height: | Size: 906 KiB After Width: | Height: | Size: 906 KiB |
|
Before Width: | Height: | Size: 1.0 MiB After Width: | Height: | Size: 1.0 MiB |
|
Before Width: | Height: | Size: 2.0 MiB After Width: | Height: | Size: 2.0 MiB |
|
Before Width: | Height: | Size: 1.3 MiB After Width: | Height: | Size: 1.3 MiB |
|
Before Width: | Height: | Size: 8.9 MiB After Width: | Height: | Size: 8.9 MiB |
|
Before Width: | Height: | Size: 1.5 MiB After Width: | Height: | Size: 1.5 MiB |
|
Before Width: | Height: | Size: 1.4 MiB After Width: | Height: | Size: 1.4 MiB |
|
Before Width: | Height: | Size: 994 KiB After Width: | Height: | Size: 994 KiB |
|
Before Width: | Height: | Size: 827 KiB After Width: | Height: | Size: 827 KiB |
|
Before Width: | Height: | Size: 403 KiB After Width: | Height: | Size: 403 KiB |
|
Before Width: | Height: | Size: 834 KiB After Width: | Height: | Size: 834 KiB |
|
Before Width: | Height: | Size: 1.2 MiB After Width: | Height: | Size: 1.2 MiB |
|
Before Width: | Height: | Size: 1.8 MiB After Width: | Height: | Size: 1.8 MiB |
|
Before Width: | Height: | Size: 658 KiB After Width: | Height: | Size: 658 KiB |
|
Before Width: | Height: | Size: 156 KiB After Width: | Height: | Size: 156 KiB |
|
Before Width: | Height: | Size: 1.1 MiB After Width: | Height: | Size: 1.1 MiB |
|
Before Width: | Height: | Size: 1.8 MiB After Width: | Height: | Size: 1.8 MiB |
|
Before Width: | Height: | Size: 1.6 MiB After Width: | Height: | Size: 1.6 MiB |
|
Before Width: | Height: | Size: 820 KiB After Width: | Height: | Size: 820 KiB |
|
Before Width: | Height: | Size: 444 KiB After Width: | Height: | Size: 444 KiB |
|
Before Width: | Height: | Size: 1.5 MiB After Width: | Height: | Size: 1.5 MiB |
|
Before Width: | Height: | Size: 365 KiB After Width: | Height: | Size: 365 KiB |
|
Before Width: | Height: | Size: 3.5 MiB After Width: | Height: | Size: 3.5 MiB |
|
Before Width: | Height: | Size: 2.5 MiB After Width: | Height: | Size: 2.5 MiB |
|
Before Width: | Height: | Size: 3.6 MiB After Width: | Height: | Size: 3.6 MiB |
|
Before Width: | Height: | Size: 3.4 MiB After Width: | Height: | Size: 3.4 MiB |
|
Before Width: | Height: | Size: 3.6 MiB After Width: | Height: | Size: 3.6 MiB |
|
Before Width: | Height: | Size: 1.7 MiB After Width: | Height: | Size: 1.7 MiB |
|
Before Width: | Height: | Size: 3.1 MiB After Width: | Height: | Size: 3.1 MiB |
BIN
KeyGenerator/keychain_3x3_perfect.pdf
Normal file
|
Before Width: | Height: | Size: 73 KiB After Width: | Height: | Size: 73 KiB |
|
Before Width: | Height: | Size: 78 KiB After Width: | Height: | Size: 78 KiB |
|
Before Width: | Height: | Size: 54 KiB After Width: | Height: | Size: 54 KiB |
|
Before Width: | Height: | Size: 73 KiB After Width: | Height: | Size: 73 KiB |
|
Before Width: | Height: | Size: 58 KiB After Width: | Height: | Size: 58 KiB |
|
Before Width: | Height: | Size: 66 KiB After Width: | Height: | Size: 66 KiB |