okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
db4dd65e5
main
1"""make_big_picture.py OUT : a 1024x1024 test picture (about 1,024 image tokens, a prompt that spans several chunks): a heading, a 2few lines of small text and coloured shapes on white.""" 3import sys 4from PIL import Image ,ImageDraw ,ImageFont 5 6im = Image .new ("RGB" , (1024 ,1024 ),"white" ) 7d = ImageDraw .Draw (im ) 8 9 10def font (size ,bold = True ): 11for f in (("arialbd.ttf" if bold else "arial.ttf" ),"C:/Windows/Fonts/arialbd.ttf" , 12"/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf" ,"/usr/share/fonts/truetype/liberation/LiberationSans-Bold.ttf" ): 13try : 14return ImageFont .truetype (f ,size ) 15except OSError : 16pass 17return ImageFont .load_default () 18 19 20d .text ((90 ,60 ),"INVOICE 20261014" ,fill = "black" ,font = font (96 )) 21d .text ((90 ,200 ),"Total due: 1337 EUR" ,fill = (20 ,20 ,160 ),font = font (64 )) 22for i ,line in enumerate (["Item 1 widgets x 12" ,"Item 2 gears x 7" ,"Item 3 springs x 30" ]): 23d .text ((90 ,320 + 70 * i ),line ,fill = "black" ,font = font (48 ,False )) 24d .ellipse ([560 ,600 ,960 ,1000 ],fill = (30 ,160 ,60 )) 25d .rectangle ([90 ,640 ,430 ,980 ],fill = (220 ,30 ,30 )) 26im .save (sys .argv [1 ]) 27"wrote" ,sys .argv [1 ])