bash -lc python - <<'PY'
from PIL import Image, ImageOps, ImageDraw, ImageFont
import os, glob, math
orig_dir='/mnt/data/pdf_compress_work/check_orig'
comp_dir='/mnt/data/pdf_compress_work/check_comp'
out='/mnt/data/pdf_compress_work/verification_contact_sheet.jpg'
orig_files=sorted(glob.glob(orig_dir+'/.png'))
comp_files=sorted(glob.glob(comp_dir+'/.png'))
create side by side pairs scaled down
pairs=[]
for o,c in zip(orig_files,comp_files):
io=Image.open(o).convert('RGB')
ic=Image.open(c).convert('RGB')
w=360
ho=round(io.heightw/io.width); hc=round(ic.heightw/ic.width)
io=io.resize((w,ho),Image.LANCZOS); ic=ic.resize((w,hc),Image.LANCZOS)
h=max(ho,hc)+30
pair=Image.new('RGB',(w*2+20,h),'white')
pair.paste(io,(0,30)); pair.paste(ic,(w+20,30))
d=ImageDraw.Draw(pair)
page=os.path.basename(o).split('.')[0]
d.text((5,5),f'{page} original',fill=(0,0,0))
d.text((w+25,5),f'{page} compressed',fill=(0,0,0))
pairs.append(pair)
cols=1
margin=15
sheet_w=max(p.width for p in pairs)
sheet_h=sum(p.height+margin for p in pairs)+margin
sheet=Image.new('RGB',(sheet_w,sheet_h),'white')
y=margin
for p in pairs:
sheet.paste(p,(0,y)); y+=p.height+margin
sheet.save(out,quality=85)
print(out)
PY
Thought for 5m 39s