#pr-app{--ink:#1d2b3a;--paper:#fff;--line:#d6dde5;--accent:#0b6e4f;--soft:#eef5f1;max-width:640px;margin:0 auto;padding:20px;border:1px solid var(--line);border-radius:10px;background:var(--paper);color:var(--ink);font:16px/1.5 system-ui,-apple-system,"Segoe UI",sans-serif;box-sizing:border-box}
@media (prefers-color-scheme:dark){#pr-app{--ink:#e8edf2;--paper:#17212b;--line:#33414f;--accent:#4cc9a0;--soft:#1f2d38}}
#pr-app *{box-sizing:border-box}
#pr-app h2{margin:0 0 4px;font-size:22px}
#pr-app p.sub{margin:0 0 16px;opacity:.75;font-size:14px}
#pr-app label{display:block;font-weight:600;font-size:14px;margin:14px 0 6px}
#pr-app .drop{display:block;border:2px dashed var(--line);border-radius:8px;padding:22px;text-align:center;cursor:pointer;background:var(--soft)}
#pr-app .drop:focus-within,#pr-app .drop:hover{border-color:var(--accent)}
#pr-app input[type=file]{width:100%}
#pr-app .chips{display:flex;flex-wrap:wrap;gap:8px}
#pr-app .chip{border:1px solid var(--line);background:transparent;color:inherit;padding:8px 12px;border-radius:20px;cursor:pointer;font:inherit;font-size:14px}
#pr-app .chip.on{background:var(--accent);border-color:var(--accent);color:#fff}
#pr-app .row{display:grid;grid-template-columns:repeat(3,1fr);gap:10px}
#pr-app input[type=number]{width:100%;padding:9px;border:1px solid var(--line);border-radius:6px;background:transparent;color:inherit;font:inherit}
#pr-app .go{width:100%;margin-top:18px;padding:13px;border:0;border-radius:8px;background:var(--accent);color:#fff;font:inherit;font-weight:700;cursor:pointer}
#pr-app .go:disabled{opacity:.5;cursor:not-allowed}
#pr-app .out{margin-top:18px;text-align:center}
#pr-app canvas{display:none}
#pr-app img{max-width:100%;max-height:260px;border:1px solid var(--line);border-radius:6px}
#pr-app .msg{margin:10px 0;font-size:15px}
#pr-app .msg.err{color:#c0392b}
#pr-app a.dl{display:inline-block;margin-top:8px;padding:11px 20px;border-radius:8px;background:var(--ink);color:var(--paper);text-decoration:none;font-weight:700}
#pr-app .note{font-size:13px;opacity:.7;margin-top:14px}

Photo & Signature Resizer
KB aur pixel size set karo. Photo aapke phone/computer se bahar nahi jati.
Width (px)
Height (px)
Max KB
Tip: Form ki exact size alag ho to upar ke boxes mein badal lo.
(function(){ var $=function(i){return document.getElementById(i)}; var file,img,fileName="image"; var f=$("pr-file"),go=$("pr-go"),out=$("pr-out"),cv=$("pr-c"); document.querySelectorAll("#pr-presets .chip").forEach(function(b){ b.addEventListener("click",function(){ document.querySelectorAll("#pr-presets .chip").forEach(function(x){x.classList.remove("on")}); b.classList.add("on"); $("pr-w").value=b.dataset.w;$("pr-h").value=b.dataset.h;$("pr-kb").value=b.dataset.kb; }); }); f.addEventListener("change",function(){ file=f.files[0];out.innerHTML="";go.disabled=true; if(!file)return; if(file.type.indexOf("image/")!==0){out.innerHTML='Sirf image file chuno (JPG, PNG, WebP).
';return} fileName=file.name.replace(/\.[^.]+$/,""); img=new Image(); img.onload=function(){go.disabled=false}; img.onerror=function(){out.innerHTML='Ye image khul nahi payi. Dusri file try karo.
'}; img.src=URL.createObjectURL(file); }); function toBlob(q){return new Promise(function(r){cv.toBlob(r,"image/jpeg",q)})} go.addEventListener("click",async function(){ var w=parseInt($("pr-w").value)||img.naturalWidth; var h=parseInt($("pr-h").value)||img.naturalHeight; var maxB=(parseFloat($("pr-kb").value)||50)*1024; go.disabled=true;out.innerHTML='Ho raha hai...
'; var scale=1,best=null; for(var attempt=0;attempt<6&&!best;attempt++){ cv.width=Math.max(10,Math.round(w*scale));cv.height=Math.max(10,Math.round(h*scale)); var ctx=cv.getContext("2d"); ctx.fillStyle="#fff";ctx.fillRect(0,0,cv.width,cv.height); ctx.drawImage(img,0,0,cv.width,cv.height); var lo=0.05,hi=0.95,ok=null; for(var i=0;i<8;i++){ var mid=(lo+hi)/2,b=await toBlob(mid); if(b.size<=maxB){ok=b;lo=mid}else{hi=mid} } if(ok)best=ok;else scale*=0.8; } go.disabled=false; if(!best){out.innerHTML='Itni chhoti KB limit mein photo nahi aa rahi. KB badha ke try karo.
';return} var url=URL.createObjectURL(best); var kb=(best.size/1024).toFixed(1); out.innerHTML=''+cv.width+' x '+cv.height+' px, '+kb+' KB
Download karo'; }); })();