import io from PIL import Image from spriteforge.studio.export import compile_asset from spriteforge.studio.models import Asset,GenerationRecipe from spriteforge.studio.store import ProjectStore def test_candidate_chroma_key_is_applied_before_export(tmp_path): store=ProjectStore.create(tmp_path/"s","ops","Ops");store.add_asset(Asset(id="item",name="Item",kind="item",target_width=16,target_height=16));_,shot=store.add_shot("item","still",0,0) image=Image.new("RGBA",(10,10),(255,0,255,255));image.paste((20,30,40,255),(4,4,6,6));out=io.BytesIO();image.save(out,"PNG") media=store.import_png(out.getvalue(),"candidate");recipe=GenerationRecipe(provider="x",model="x",seed=0,prompt="x",width=64,height=64);_,candidate=store.add_candidate("item",shot.id,media,recipe) store.update_candidate("item",shot.id,candidate.id,{"process":{"alpha_threshold":128,"chroma_key":"#FF00FF","chroma_tolerance":0}});store.decide("item",shot.id,candidate.id,"approved") raw=compile_asset(store,store.load().assets[0]);assert raw.frames[0].rgba.shape[:2]==(2,2)