PageSourceSearch

https://conversiontab.com/build/assets/grayscale-image-page-Cy6PkibV.js

js conversiontab.com collected 2026-09-24 10:07:32 UTC 2,366 bytes, 1 lines download raw bytes

1import{saveResultFile as v}from"./ctResultAccessAd-Dk9whJZs.js";import{w,c as B}from"./fileDropzone-CA_uaFcV.js";import"./FileSaver.min-BR20wtAe.js";import"./_commonjsHelpers-BosuxZz1.js";import"./ctFullscreenAd-CL-AA_Ul.js";import"./app-gOHIPY12.js";import"./transientNotice-Ds_di7lD.js";const E=15*1024*1024;function L(i){const e=new Image;e.src=URL.createObjectURL(i),e.onload=()=>{const n=document.createElement("canvas");n.width=e.width,n.height=e.height;const s=n.getContext("2d");if(!s){URL.revokeObjectURL(e.src);return}s.drawImage(e,0,0);const c=s.getImageData(0,0,n.width,n.height),o=c.data;for(let t=0;t<o.length;t+=4){const r=(o[t]+o[t+1]+o[t+2])/3;o[t]=r,o[t+1]=r,o[t+2]=r}s.putImageData(c,0,0),n.toBlob(t=>{if(URL.revokeObjectURL(e.src),!t)return;const r=(i.name||"image").replace(/\.[^/.]+$/,"");v(t,`${r}-grayscale.png`)},"image/png")},e.onerror=()=>{URL.revokeObjectURL(e.src)}}function g(i){const e=document.getElementById("ctGrayToastBody"),n=document.getElementById("ctGrayToast");if(!e||!n||typeof bootstrap>"u"){window.alert(i);return}e.textContent=i,bootstrap.Toast.getOrCreateInstance(n).show()}function D(){if(!document.getElementById("ct-grayscale-image-root"))return;const e=document.getElementById("ctGrayFile"),n=document.getElementById("ctGrayDrop"),s=document.getElementById("ctGrayDropCaption"),c=document.getElementById("ctGrayResultCard"),o=document.getElementById("ctGrayOrigImg"),t=document.getElementById("ctGrayPreviewImg"),r=document.getElementById("ctGrayDownloadBtn"),u=document.getElementById("ctGrayResetBtn");if(!e||!n||!c||!o||!t||!r||!u)return;const f="url(#ctGrayscalePreviewFe)";let d=null;function y(){d&&(URL.revokeObjectURL(d),d=null)}function m(){y(),o.removeAttribute("src"),t.removeAttribute("src"),t.style.filter="",c.classList.add("d-none"),B(e)}function I(){var p;y();const a=(p=e.files)==null?void 0:p[0];if(!a){c.classList.add("d-none");return}if(a.size>E){g("File is too large (max 15 MB)."),m();return}d=URL.createObjectURL(a);const l=()=>{g("Could not read that image."),m()};o.addEventListener("error",l,{once:!0}),o.src=d,t.src=d,t.style.filter=f,c.classList.remove("d-none")}w({input:e,drop:n,captionEl:s,onChange:I,onInvalidFile:a=>g(a)}),r.addEventListener("click",()=>{var l;const a=(l=e.files)==null?void 0:l[0];a&&L(a)}),u.addEventListener("click",()=>{m()})}export{D as initGrayscaleImagePage};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.