Package
ci / checks (push) Successful in 48m34s

This commit is contained in:
khodowany
2026-09-30 19:46:37 -05:00
parent 2a1aa2c67a
commit 09656a9d60
6621 changed files with 698 additions and 774 deletions
+5 -3
View File
@@ -9,6 +9,7 @@ import PIL.Image
import PIL.ImageChops
import generator.engraving.types
import generator.theme
ENGINE_NAME = 'Vamp Python'
PAGE_WIDTH = 976
@@ -19,9 +20,10 @@ def check_content(data: bytes, name: str) -> None:
if image.format != 'PNG' or image.size != (PAGE_WIDTH, PAGE_HEIGHT):
raise generator.engraving.types.EngravingError(f'{name}: expected a {PAGE_WIDTH}x{PAGE_HEIGHT} PNG page')
image.load()
white = PIL.Image.new('RGBA', image.size, 'white')
white.alpha_composite(image.convert('RGBA'))
ink = PIL.ImageChops.difference(white.convert('RGB'), PIL.Image.new('RGB', image.size, 'white')).convert('L').point(lambda x: 255 if x > 32 else 0)
background = PIL.Image.new('RGB', image.size, generator.theme.rgb('background'))
composited = background.convert('RGBA')
composited.alpha_composite(image.convert('RGBA'))
ink = PIL.ImageChops.difference(composited.convert('RGB'), background).convert('L').point(lambda x: 255 if x > 32 else 0)
bounds = ink.getbbox()
if not bounds:
raise generator.engraving.types.EngravingError(f'{name}: engraver produced a blank page')