from pathlib import Path
from PIL import Image
from collections import Counter
import struct,io,json,hashlib,shutil
p=Path(__file__).resolve().parent; f=p/'png-alpha-four-bands.ico'; b=f.read_bytes()
r={'date':'2026-10-26','method':'Actual Chrome homepage file picker, Convert to ICO, download. Pillow independently decodes each PNG entry.','source_sha256':hashlib.sha256((p/'png-alpha-four-bands.png').read_bytes()).hexdigest(),'ico_sha256':hashlib.sha256(b).hexdigest(),'bytes':len(b),'frames':[]}
for i in range(struct.unpack_from('<H',b,4)[0]):
 w,h,_,_,planes,bits,n,off=struct.unpack_from('<BBBBHHII',b,6+16*i); im=Image.open(io.BytesIO(b[off:off+n])).convert('RGBA'); c=Counter(im.getchannel('A').getdata()); r['frames'].append({'size':im.width,'bytes':n,'alpha_counts':dict(sorted(c.items())),'transparent':c[0],'partial':sum(v for k,v in c.items() if 0<k<255),'opaque':c[255]})
(p/'measurements.json').write_text(json.dumps(r,indent=2),encoding='utf8');print(json.dumps(r,indent=2))
