-- Native-pixel colour correction only; preserve geometry, alpha and all other art. local sprite=app.open(app.params.source) local image=sprite.cels[1].image local mode=app.params.mode or 'portrait' for pixel in image:pixels() do local c=pixel() local r,g,b,a=app.pixelColor.rgbaR(c),app.pixelColor.rgbaG(c),app.pixelColor.rgbaB(c),app.pixelColor.rgbaA(c) local y=pixel.y local in_hair=false if mode=='portrait' then in_hair=y0 and r>=18 and r<160 and b>=r*0.45 and g>=r*0.64 and r>=b*0.92 then local lum=0.299*r+0.587*g+0.114*b local value=math.floor(lum*0.66) pixel(app.pixelColor.rgba(math.max(7,value-4),math.max(9,value-1),math.max(12,value+3),a)) end end sprite:saveAs(app.params.output) sprite:close()