#!/usr/bin/env python3 """Reproduce only the fitted art and review sizes; never assemble a card.""" from pathlib import Path from PIL import Image, ImageOps import hashlib,json root=Path(__file__).resolve().parent.parent native=root/'source/art-native.png' with Image.open(native) as source: im=source.convert('RGB');w,h=im.size scale=max(2000/w,2800/h) art=ImageOps.fit(im,(2000,2800),Image.Resampling.LANCZOS,centering=(.5,.5)) art.save(root/'source/art-master.png') for name,size in [('art-review.png',(1000,1400)),('art-card-size.png',(500,700)),('art-thumbnail.png',(250,350))]: art.resize(size,Image.Resampling.LANCZOS).save(root/'review'/name) fit={'source':'art-native.png','sourceDimensions':[w,h],'canvas':[2000,2800],'method':'uniform centered cover fit','scale':scale,'scaledDimensions':[w*scale,h*scale],'cropOffset':[(w*scale-2000)/2,(h*scale-2800)/2],'resampling':'Pillow LANCZOS','sourceSHA256':hashlib.sha256(native.read_bytes()).hexdigest(),'outputSHA256':hashlib.sha256((root/'source/art-master.png').read_bytes()).hexdigest()} (root/'source/art-fit.json').write_text(json.dumps(fit,indent=2)+'\n')