const sharp = require('sharp'); const p = 'data/media/assets/e6/e64a43a218fa7471fb0713652d383736757a81c004ced24c920b142d265acf58.png'; const pts = { podloga_wnetrze_1: [1200, 700], podloga_wnetrze_2: [900, 900], podloga_wnetrze_3: [1400, 550], sciana_wnetrze: [1000, 480], pas_przedni_tk: [1200, 1250], siedzisko_spod_tk: [700, 400], listwa_drewno: [520, 1000], podlokietnik_tk: [1750, 850], siedzisko_prawe_tk:[2050, 1300], tlo_studio: [200, 1600], }; function rgbToLab(r,g,b){ const lin=c=>{c/=255;return c<=0.04045?c/12.92:Math.pow((c+0.055)/1.055,2.4)}; const rl=lin(r),gl=lin(g),bl=lin(b); const x=(rl*0.4124564+gl*0.3575761+bl*0.1804375)/0.95047; const y=rl*0.2126729+gl*0.7151522+bl*0.072175; const z=(rl*0.0193339+gl*0.119192+bl*0.9503041)/1.08883; const f=t=>t>0.008856?Math.cbrt(t):7.787*t+16/116; const fx=f(x),fy=f(y),fz=f(z); return [116*fy-16,500*(fx-fy),200*(fy-fz)]; } (async()=>{ const img = sharp(p).removeAlpha(); for (const [name,[x,y]] of Object.entries(pts)) { const raw = await img.clone().extract({left:Math.max(0,x-5),top:Math.max(0,y-5),width:11,height:11}).raw().toBuffer(); let r=0,g=0,b=0,n=0; for (let i=0;iv.toFixed(1)); console.log(name.padEnd(20), `rgb(${r},${g},${b})`.padEnd(20), `LAB(${L}, ${A}, ${B})`); } })();