cropper / app /static /cropper.html
cropper deploy
Deploy 78af8ca
1ab7be6
Raw History Blame Contribute Delete
7.89 kB
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Cropper</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<header>
<h1>Cropper</h1>
<p class="sub">X-ray specimen grid &rarr; individual images</p>
</header>
<main>
<aside>
<section>
<h2>1. Boxes &mdash; <span id="trayTitle">X-ray tray</span></h2>
<div class="row">
<button id="btnPhoto" class="ghost">Change photo</button>
<button id="btnFrame" class="ghost" disabled>Adjust frame</button>
</div>
<button id="btnInherit" class="ghost" hidden>Use the X-ray&rsquo;s grid</button>
<label class="spaced">Specimens on the tray
<input type="number" id="count" value="6" min="1" max="2500">
</label>
<div class="row spaced">
<label>Rows <input type="number" id="rows" min="1" max="50" placeholder="auto"></label>
<label>Columns <input type="number" id="cols" min="1" max="50" placeholder="auto"></label>
</div>
<p class="muted">Leave both blank and the rows and columns are banded off the
samples themselves. Fill them in when the tray is one the banding reads wrong.</p>
<details class="card" name="mode" open>
<summary>Auto-detect</summary>
<div class="cardBody">
<p class="muted">Finds the samples and works out the grid they lie in on its
own &mdash; a dot goes where each sample&rsquo;s diagonals cross, and its
rectangle grows from that dot until the sample is covered or the next
rectangle is in the way.</p>
<button id="btnDetect" disabled>Detect samples</button>
</div>
</details>
<details class="card" name="mode">
<summary>Click each sample</summary>
<div class="cardBody">
<p class="muted">For a photo the detector cannot read. Click once on each of the
<span id="seedTarget">6</span> samples, in any order &mdash; the rows and
columns are read off where you clicked.</p>
<button id="btnSeed" class="ghost" disabled>Place dots</button>
<button id="btnGrow" disabled>Create rectangles from dots</button>
</div>
</details>
<details class="card" name="mode">
<summary>One size for all</summary>
<div class="cardBody">
<label>Packing
<select id="fit">
<option value="fill">Packed &mdash; as large as they all fit</option>
<option value="cover">Tight &mdash; around the biggest sample</option>
</select>
</label>
<button id="btnUniform" disabled>Detect samples</button>
</div>
</details>
<label class="spaced">Box size <span class="boxPctVal">100%</span>
<input type="range" class="boxPct" min="10" max="100" step="1" value="100">
</label>
<div class="muted boxInfo"></div>
<details class="card plain">
<summary>Move the whole grid</summary>
<div class="cardBody">
<p class="muted">Every box at once, about the grid&rsquo;s centre &mdash; for a
grid that is out by one shift or one small turn, which is what the label
photo usually is. A box you dragged or drew by hand is left where you put it.</p>
<label>Shift across <span class="adjVal" data-k="dx">0.0%</span>
<input type="range" class="adj" data-k="dx" min="-25" max="25" step="0.2" value="0"></label>
<label>Shift down <span class="adjVal" data-k="dy">0.0%</span>
<input type="range" class="adj" data-k="dy" min="-25" max="25" step="0.2" value="0"></label>
<label>Scale <span class="adjVal" data-k="scale">1.00&times;</span>
<input type="range" class="adj" data-k="scale" min="0.4" max="2" step="0.005" value="1"></label>
<label>Column spacing <span class="adjVal" data-k="gapx">1.00&times;</span>
<input type="range" class="adj" data-k="gapx" min="0.5" max="1.8" step="0.005" value="1"></label>
<label>Row spacing <span class="adjVal" data-k="gapy">1.00&times;</span>
<input type="range" class="adj" data-k="gapy" min="0.5" max="1.8" step="0.005" value="1"></label>
<label>Rotate <span class="adjVal" data-k="rot">0.0&deg;</span>
<input type="range" class="adj" data-k="rot" min="-15" max="15" step="0.1" value="0"></label>
<button id="btnAdjReset" class="ghost">Sliders back to neutral</button>
</div>
</details>
</section>
<section id="namesPanel" hidden>
<h2>2. Names &mdash; label tray</h2>
<label>Label reader
<select id="engine">
<option value="tesseract">Printed labels — fast</option>
<option value="handwriting">Handwritten labels — TrOCR, slow</option>
</select>
</label>
<label class="spaced">Series prefix <span class="muted">&mdash; optional</span>
<input type="text" id="prefix" placeholder="20240729-001" maxlength="20">
</label>
<p class="muted">A label is <code>XXXXXXXX-XXX-XX</code> &mdash; thirteen digits. A read
that cannot make that shape comes back empty; type it from the crop beside the field.
Give the head this tray&rsquo;s labels share and a read of the last two digits alone
is enough &mdash; on handwriting that is usually the whole difference.</p>
<label class="spaced">Label strip <span class="val" id="bandVal">35%</span>
<input type="range" id="band" min="5" max="100" step="1" value="35">
</label>
<p class="muted">The bottom slice of every box, where the writing is. It fills the
text areas for you &mdash; read from, shown beside each name, exported as
<code>{name}_text.jpg</code>. Drag any strip the slider got wrong and it stays put.</p>
<button id="btnReread" disabled>Read the names</button>
<button id="btnDraw" class="ghost" disabled>Draw a name box</button>
<button id="btnText" class="ghost" disabled>Select text areas</button>
</section>
<section id="outputPanel">
<h2>3. Output</h2>
<div class="row">
<label>Width<input type="number" id="outW" value="512" min="16" max="8000"></label>
<label>Height<input type="number" id="outH" value="512" min="16" max="8000"></label>
</div>
<label class="chk"><input type="checkbox" id="keepAspect"> Keep aspect (pad black)</label>
<label class="chk"><input type="checkbox" id="native"> Match X-ray (no resize)</label>
<button id="btnCrop" disabled>Crop &amp; download ZIP</button>
</section>
</aside>
<div class="workspace">
<div class="modes">
<button id="modeXray" class="mode on" type="button">1 &middot; X-ray tray</button>
<button id="modeLabel" class="mode" type="button">2 &middot; Label tray &amp; names</button>
</div>
<input type="file" id="file" accept="image/*" hidden>
<input type="file" id="labelFile" accept="image/*" hidden>
<div id="status" class="status">Upload the X-ray of a tray to start.</div>
<div id="canvasWrap">
<div id="dropZone">
<svg class="ph" viewBox="0 0 160 90" preserveAspectRatio="none" aria-hidden="true">
<rect x="0.5" y="0.5" width="159" height="89"></rect>
<line x1="0.5" y1="0.5" x2="159.5" y2="89.5"></line>
<line x1="159.5" y1="0.5" x2="0.5" y2="89.5"></line>
</svg>
<span class="slotHint">Select photo</span>
</div>
<canvas id="canvas"></canvas>
</div>
<div id="hint" class="muted"></div>
<h2>Specimen names <span id="review" class="badge" hidden></span></h2>
<div id="chips"></div>
<div id="tableWrap" class="muted">Detect the samples first.</div>
</div>
</main>
<script src="app.js"></script>
</body>
</html>