iccdev
Version:
The International Color Consortium....promoting and encouraging the standardization of an open color management system with WASM Tools for managing ICC Color Profiles
78 lines (67 loc) • 2.87 kB
HTML
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Extract ICC from TIFF</title>
<style>
body { font-family: Arial, sans-serif; margin: 20px; }
textarea { width: 100%; box-sizing: border-box; margin-top: 10px; }
label { display: block; margin-top: 0.5em; }
</style>
</head>
<body>
<header>
<div>
<a href="https://color.org/index.xalter">
<img src="https://color.org/system/images/ICC_logo_text.gif" width="368" height="27" alt="International Color Consortium">
</a>
</div>
<div>
<img src="https://color.org/system/images/ICC_logo_top.gif" width="143" height="65" alt="ICC Logo">
<img src="https://color.org/system/images/hd_images.jpg" width="657" height="46" alt="Making color seamless between devices and documents">
</div>
</header>
<h1>Extract Embedded ICC Profile from TIFF</h1>
<section>
<input type="file" id="tiffInput" accept=".tif,.tiff" />
<button onclick="extractICC()">Extract ICC</button>
<a id="downloadLink" style="display:none">Download ICC</a>
<textarea id="tiffOutput" rows="20" placeholder="TIFF metadata and status will appear here..."></textarea>
</section>
<script src="iccTiffDump.js"></script>
<script>
const createModule_IccTiffDump = createModule;
let iccTiffDumpInstance;
const iccTiffDumpReady = createModule_IccTiffDump({
print: text => document.getElementById("tiffOutput").value += text + "\n",
printErr: text => document.getElementById("tiffOutput").value += "ERR: " + text + "\n"
}).then(mod => iccTiffDumpInstance = mod);
async function extractICC() {
await iccTiffDumpReady;
const file = document.getElementById("tiffInput").files[0];
if (!file) return alert("No TIFF image selected.");
document.getElementById("tiffOutput").value = "";
document.getElementById("downloadLink").style.display = "none";
const reader = new FileReader();
reader.onload = () => {
try {
const data = new Uint8Array(reader.result);
iccTiffDumpInstance.FS.writeFile("in.tif", data);
iccTiffDumpInstance.callMain(["in.tif", "out.icc"]);
const icc = iccTiffDumpInstance.FS.readFile("out.icc");
const blob = new Blob([icc], { type: "application/octet-stream" });
const link = document.getElementById("downloadLink");
link.href = URL.createObjectURL(blob);
link.download = "extracted.icc";
link.textContent = "Download Extracted ICC";
link.style.display = "inline";
} catch (err) {
console.error("Extraction failed:", err);
alert("Failed to extract ICC.");
}
};
reader.readAsArrayBuffer(file);
}
</script>
</body>
</html>