<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Mike Printz</title>
    <description>The latest articles on DEV Community by Mike Printz (@getdropsheet).</description>
    <link>https://dev.to/getdropsheet</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4148265%2F39fd2411-78ca-45fc-b599-54469e35a8fc.png</url>
      <title>DEV Community: Mike Printz</title>
      <link>https://dev.to/getdropsheet</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/getdropsheet"/>
    <language>en</language>
    <item>
      <title>I built a Pokémon card grader</title>
      <dc:creator>Mike Printz</dc:creator>
      <pubDate>Fri, 06 Nov 2026 15:53:18 +0000</pubDate>
      <link>https://dev.to/getdropsheet/i-built-a-pokemon-card-grader-1pbj</link>
      <guid>https://dev.to/getdropsheet/i-built-a-pokemon-card-grader-1pbj</guid>
      <description>&lt;p&gt;Grading a Pokémon card at PSA costs about $65 to $85 once you add shipping, and it takes months. A lot of cards come back worth less than that. So before sending anything off, collectors squint at their cards, guess at the centering, look up a few sold listings and hope.&lt;/p&gt;

&lt;p&gt;I wanted that guess to be a measurement. The result is &lt;a href="https://shouldigradeit.app" rel="noopener noreferrer"&gt;Should I Grade It?&lt;/a&gt;: you photograph a card, it estimates the PSA grade, finds what the card sells for raw and at that grade, and tells you whether grading pays after fees.&lt;/p&gt;

&lt;p&gt;This post covers how it works, and more usefully, the things that broke once real people and real crawlers showed up.&lt;/p&gt;

&lt;h2&gt;
  
  
  The stack
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The app&lt;/strong&gt; is one HTML file with no framework and no build step, about 4,000 lines. All the image measurement happens in the browser with canvas, so photos never have to leave the phone to be measured.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A Cloudflare Worker&lt;/strong&gt; handles everything that needs a server: card identification, prices, accounts, Stripe and 25,000 server-rendered price pages.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Workers KV&lt;/strong&gt; stores the card catalog, refreshed nightly by a cron trigger.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Data:&lt;/strong&gt; &lt;a href="https://cardsight.ai" rel="noopener noreferrer"&gt;CardSight AI&lt;/a&gt; identifies the card from the photo, &lt;a href="https://tcgcsv.com" rel="noopener noreferrer"&gt;TCGCSV&lt;/a&gt; mirrors TCGplayer's catalog and market prices, and &lt;a href="https://www.pokemonpricetracker.com" rel="noopener noreferrer"&gt;PokemonPriceTracker&lt;/a&gt; supplies recent eBay sales of graded copies.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Static pages&lt;/strong&gt; are on Cloudflare Pages.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Measuring centering with canvas
&lt;/h2&gt;

&lt;p&gt;Centering is the one part of a grade you can actually measure from a photo, and it caps everything else. PSA publishes the limits: a 10 needs the front borders within 55/45, a 9 within 60/40, and so on down the scale.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// PSA's front centering limits: [the larger side of the split, the best grade it allows]&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;PSA_CENTER&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[[&lt;/span&gt;&lt;span class="mi"&gt;55&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;],[&lt;/span&gt;&lt;span class="mi"&gt;60&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="p"&gt;],[&lt;/span&gt;&lt;span class="mi"&gt;65&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;],[&lt;/span&gt;&lt;span class="mi"&gt;70&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="p"&gt;],[&lt;/span&gt;&lt;span class="mi"&gt;75&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;],[&lt;/span&gt;&lt;span class="mi"&gt;80&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;],[&lt;/span&gt;&lt;span class="mi"&gt;85&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;],[&lt;/span&gt;&lt;span class="mi"&gt;90&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;]];&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;centeringCap&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;left&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;right&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;big&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;left&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;right&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;left&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;right&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;   &lt;span class="c1"&gt;// 55.4 for a 55.4/44.6 split&lt;/span&gt;
  &lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;limit&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;grade&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="nx"&gt;PSA_CENTER&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;big&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="nx"&gt;limit&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;grade&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The hard part is getting &lt;code&gt;left&lt;/code&gt; and &lt;code&gt;right&lt;/code&gt; from a phone photo. Most vintage cards have a yellow border, which makes a good target: convert to HSV, keep the pixels in the yellow hue band, take the largest shape, fit four corners and warp the card flat. Then walk inward from each edge until the yellow stops and the artwork box starts. Those four distances are the borders.&lt;/p&gt;

&lt;p&gt;Phone photos fight you at every step. Glare washes out the border, sleeves add a second edge, and a card shot at a slight angle reads as off-center when it isn't. I spent more time on rejecting bad photos than on measuring good ones.&lt;/p&gt;

&lt;h2&gt;
  
  
  Don't trust your own measurement
&lt;/h2&gt;

&lt;p&gt;An automatic measurement that's 2% off can be the difference between a 9 and a 10, so I added an inspector: the straightened card at full resolution, with four draggable lines placed where the app measured. You can zoom to 8x, run a magnifier along the edge, and switch to an edge-detection filter that makes print lines and whitening jump out. Drag a line and the split and grade update live.&lt;/p&gt;

&lt;p&gt;It worked perfectly on the standalone centering tool page. In the app, it opened to a black screen, and my test suite passed anyway, because the test only checked that the overlay opened with the right title.&lt;/p&gt;

&lt;p&gt;The cause was one line of CSS. The app processes photos on hidden canvases, so its stylesheet had:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;canvas&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;none&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;which also hid the inspector's canvas, the one thing on that screen meant to be seen. The fix was a single &lt;code&gt;display: block !important&lt;/code&gt; in the inspector's own styles. The lesson cost more: my test now screenshots the inspector and checks that the middle of the screen is actually showing a card.&lt;/p&gt;

&lt;h2&gt;
  
  
  The day KV ran out
&lt;/h2&gt;

&lt;p&gt;The day after I launched the card price pages, Cloudflare emailed: I'd used the free tier's 100,000 KV reads for the day, and every read would fail until midnight UTC.&lt;/p&gt;

&lt;p&gt;I counted reads per request in a test harness. Each card page cost &lt;strong&gt;19 reads&lt;/strong&gt;: the set list, the catalog state, the set's cards, two months of price history, and then the same card number in up to 12 other sets for an "also printed in" section. Google and Bing were crawling thousands of pages a day from the sitemap.&lt;/p&gt;

&lt;p&gt;The fix was to stop re-reading data that every request needs. A Worker isolate stays warm between requests, so a small in-memory cache with a short lifetime goes a long way:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;MEMO&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Map&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="nx"&gt;MEMO_MAX&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;60&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;kvJSON&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;ttlMs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;600000&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;m&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;MEMO&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;m&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;m&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exp&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;now&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;m&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;v&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;raw&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;CARDS&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;cacheTtl&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;3600&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;v&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;raw&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;raw&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nx"&gt;MEMO&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;v&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;exp&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;now&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;ttlMs&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;MEMO&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;size&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;MEMO_MAX&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nx"&gt;MEMO&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;delete&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;MEMO&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;keys&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;next&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;   &lt;span class="c1"&gt;// oldest first&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;v&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;cacheTtl&lt;/code&gt; doesn't save you here: a read served from Cloudflare's cache still counts against the KV allowance. The memo does. I also dropped the other-sets lookup to links built from the set list already in memory, and put the homepage's live data behind the Workers Cache API for an hour.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;Before&lt;/th&gt;
&lt;th&gt;After&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;One crawled card page&lt;/td&gt;
&lt;td&gt;19 reads&lt;/td&gt;
&lt;td&gt;1.1 reads&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;20 homepage visits&lt;/td&gt;
&lt;td&gt;about 80 reads&lt;/td&gt;
&lt;td&gt;3 reads&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Then I upgraded to the $5 Workers Paid plan anyway. Ten million reads a month is cheap insurance, and the efficiency work means I'll rarely touch it.&lt;/p&gt;

&lt;h2&gt;
  
  
  eBay says no
&lt;/h2&gt;

&lt;p&gt;Lots of people decide whether to buy a card from an eBay listing, so I added "paste a listing link": the Worker fetches the page, pulls the photo URLs and sorts them into front and back.&lt;/p&gt;

&lt;p&gt;eBay answers a Worker with a 403. The photos themselves download fine from eBay's image CDN; it's the listing page that's protected. I could have routed around the block through a third-party scraping proxy, but eBay blocks automated readers deliberately, and anything built on getting past that breaks without warning.&lt;/p&gt;

&lt;p&gt;The visitor's own browser, though, is already looking at the listing. So the answer was a bookmarklet: drag "Grade this listing" to the bookmarks bar, click it on any listing, and it reads the photo URLs from the page you're viewing and opens the app with them.&lt;/p&gt;

&lt;p&gt;The first version grabbed 88 photos from a page whose listing had ended, because eBay had redirected to a page of other sellers' items. The fix was to read only the listing's own gallery and refuse anything that isn't a single listing:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;onEbay&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="se"&gt;(&lt;/span&gt;&lt;span class="sr"&gt;^|&lt;/span&gt;&lt;span class="se"&gt;\.)&lt;/span&gt;&lt;span class="sr"&gt;ebay&lt;/span&gt;&lt;span class="se"&gt;\.[&lt;/span&gt;&lt;span class="sr"&gt;a-z.&lt;/span&gt;&lt;span class="se"&gt;]{2,8}&lt;/span&gt;&lt;span class="sr"&gt;$/i&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;test&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;location&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;hostname&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;onEbay&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="se"&gt;\/&lt;/span&gt;&lt;span class="sr"&gt;itm&lt;/span&gt;&lt;span class="se"&gt;\/&lt;/span&gt;&lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;test&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;location&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;pathname&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;alert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Open a single eBay listing first, then click this again.&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="c1"&gt;// only the listing's own gallery, never similar items or recommendations&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;scope&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;querySelector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;[data-testid="x-photos"], #PicturePanel, .ux-image-carousel-container&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On a live listing that took exactly the 12 gallery photos and skipped the other 30 eBay images on the page.&lt;/p&gt;

&lt;h2&gt;
  
  
  A memory leak hiding in plain sight
&lt;/h2&gt;

&lt;p&gt;Every time the app read a photo, to sort it, measure it or draw a thumbnail, it did this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;img&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;src&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;URL&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createObjectURL&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;file&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and never called &lt;code&gt;revokeObjectURL&lt;/code&gt;. Each call pins the whole file in memory until the page closes. A phone photo is 3 to 5 MB, a scan reads each photo several times, and thumbnails were recreated on every redraw. Scanning one 12-photo listing left 44 copies in memory, which is how you get Safari quietly reloading the tab on an iPhone.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;u&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;URL&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createObjectURL&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;file&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;img&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;onload&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;URL&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;revokeObjectURL&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;u&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="nf"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;img&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;   &lt;span class="c1"&gt;// decoded, so the copy can go&lt;/span&gt;
&lt;span class="nx"&gt;img&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;src&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;u&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Thumbnails now reuse one URL per file from a &lt;code&gt;WeakMap&lt;/code&gt;. Same 12-photo scan: 12 copies held, one per thumbnail, all of them needed.&lt;/p&gt;

&lt;h2&gt;
  
  
  25,000 pages and what Google thinks of them
&lt;/h2&gt;

&lt;p&gt;Every card in the catalog gets a server-rendered price page from the Worker: the raw price, a 30-day sparkline drawn as inline SVG, graded values and printings. Soon after launch, Search Console said 811 indexed and 24,100 not indexed. Opening each reason showed which parts were fixable:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;22,304 "discovered, not indexed".&lt;/strong&gt; Google found them in the sitemap and hasn't visited yet. That's the crawl budget of a new domain, and only time and links fix it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;451 "page with redirect".&lt;/strong&gt; Not card pages at all: every card page linked to &lt;code&gt;/app?q=...&lt;/code&gt;, so Google was crawling thousands of variations of one app page. Those links are now &lt;code&gt;rel="nofollow"&lt;/code&gt; and &lt;code&gt;robots.txt&lt;/code&gt; disallows &lt;code&gt;/app?&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;1,274 "crawled, not indexed".&lt;/strong&gt; Mostly 25-cent commons with near-identical pages, some with broken images for cards that have no photo.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So the sitemap now lists only cards worth a dollar or more, pages for cards without a price ask not to be indexed, missing photos get a placeholder instead of a broken image, and each page gets an "at a glance" section of facts unique to that card: its rank in the set, its 30-day range, and its most valuable printing.&lt;/p&gt;

&lt;h2&gt;
  
  
  Testing a framework-free app
&lt;/h2&gt;

&lt;p&gt;There's no framework, so there's no framework test runner either. What I use:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Plain Playwright scripts&lt;/strong&gt; for each feature, with the Worker mocked at the network layer, about 140 checks in all. Each runs at phone and desktop sizes and fails on any page error.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;TypeScript as a linter for plain JavaScript.&lt;/strong&gt; &lt;code&gt;tsc --allowJs --checkJs --noUnusedLocals&lt;/code&gt; over the extracted scripts, filtered to the errors that matter: undefined names, duplicate declarations, unused code. It found nine pieces of dead code, including a call to the most expensive function in the app whose result was thrown away on every photo.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The real security headers in tests.&lt;/strong&gt; A small local server applies the same &lt;code&gt;_headers&lt;/code&gt; file Cloudflare Pages uses, so a Content Security Policy that blocks something fails a test rather than a user.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Where it is now
&lt;/h2&gt;

&lt;p&gt;It's live at &lt;a href="https://shouldigradeit.app" rel="noopener noreferrer"&gt;shouldigradeit.app&lt;/a&gt;, free for 7 scans a month. The centering tool and grading calculator are free with no account. PSA reopened its cheaper Value tier this week, which meant updating the grading-cost maths from one flat fee to the tier each card's value requires, since a $5,000 card can't go through a tier capped at $500.&lt;/p&gt;

&lt;p&gt;If you've worked on measuring things from phone photos, I'd love to hear how you handled glare and perspective. And if you collect, tell me what it gets wrong.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>cloudflare</category>
      <category>showdev</category>
    </item>
    <item>
      <title>I ran OCR in the browser so receipt images never leave the device</title>
      <dc:creator>Mike Printz</dc:creator>
      <pubDate>Tue, 29 Sep 2026 01:13:13 +0000</pubDate>
      <link>https://dev.to/getdropsheet/i-ran-ocr-in-the-browser-so-receipt-images-never-leave-the-device-22aj</link>
      <guid>https://dev.to/getdropsheet/i-ran-ocr-in-the-browser-so-receipt-images-never-leave-the-device-22aj</guid>
      <description>&lt;p&gt;Every receipt scanner I looked at uploaded the image to a server to read it. That makes sense technically. It made no sense to me otherwise.&lt;/p&gt;

&lt;p&gt;A year of receipts is a fairly complete picture of a person. Which pharmacy you use. Which bar. Whether you hired a lawyer. Where you were on a Tuesday night in March. Most of them carry the last four of your card across the bottom. I did not want mine sitting on someone else's disk, and I did not want to explain to anyone else why they should be comfortable with theirs.&lt;/p&gt;

&lt;p&gt;So I tried to do the whole thing in the browser. No server, no upload, no account. Here is what that actually cost.&lt;/p&gt;

&lt;p&gt;Tesseract.js is the easy part and the slow part&lt;/p&gt;

&lt;p&gt;The OCR itself is tesseract.js, loaded from a CDN. Getting text out of an image is about ten lines.&lt;/p&gt;

&lt;p&gt;The cost is weight and time. You are shipping a WASM build and a trained language model to the browser before anything happens. On a desktop with a warm cache it is fine. On a phone, on mobile data, the first run is noticeably slower than anyone expects from a web page.&lt;/p&gt;

&lt;p&gt;The mitigation is boring but it works: load the libraries once at page load rather than on demand, and let the browser cache do the rest. After the first visit the tool runs offline. That is a nice property to have accidentally.&lt;/p&gt;

&lt;p&gt;A digital PDF receipt reads essentially instantly, because there is real text in the file and no OCR is needed at all. A phone photo of a printed receipt takes a few seconds. A bad photo takes longer and returns worse text.&lt;/p&gt;

&lt;p&gt;Faded thermal paper defeats it completely&lt;/p&gt;

&lt;p&gt;This is the part I would tell anyone building in this space first.&lt;/p&gt;

&lt;p&gt;Thermal receipts do not use ink. They use a heat sensitive dye that keeps reacting after you leave the store. Heat accelerates it, so does sunlight, so does the plastic in a wallet. A gas receipt that spent a summer in a glovebox is often blank by spring. Not faint. Blank.&lt;/p&gt;

&lt;p&gt;No OCR engine recovers that, because there is nothing left to recover. Mine does not either.&lt;/p&gt;

&lt;p&gt;The design question is what you do about it, and I think this is where most tools get it wrong. The tempting behaviour is to return a best guess and let it look like a successful read. That is worse than failing, because the user has no signal that a number in their spreadsheet is fiction.&lt;/p&gt;

&lt;p&gt;So the row stays on the sheet, flagged, with the total left empty. The footer says something like "3 of 4 read, 1 needs a total." You type the missing one yourself.&lt;/p&gt;

&lt;p&gt;It makes the product look less capable in a demo. It makes it trustworthy in use. Given the output ends up in a tax return, that is not a close call.&lt;/p&gt;

&lt;p&gt;Parsing is the part nobody writes about&lt;/p&gt;

&lt;p&gt;OCR gives you a blob of text. Turning that into date, vendor, total, tax is where most of the actual work lives, and it is unglamorous.&lt;/p&gt;

&lt;p&gt;Some of the problems:&lt;/p&gt;

&lt;p&gt;Totals are not labelled consistently. TOTAL, AMOUNT DUE, BALANCE, or nothing at all. Sometimes the largest number on the receipt is the total. Sometimes it is the cash tendered.&lt;/p&gt;

&lt;p&gt;Dates come in every format a point of sale system has ever emitted, and OCR will happily turn a 0 into an O or an 8 into a B.&lt;/p&gt;

&lt;p&gt;The vendor name is usually the first line, except when the first line is a slogan, a store number, or an address.&lt;/p&gt;

&lt;p&gt;Tax lines look like totals.&lt;/p&gt;

&lt;p&gt;There is no clever solution here. It is heuristics, tested against a pile of real receipts, adjusted when something breaks. Anyone claiming otherwise is either using a hosted service or has not tried enough receipts.&lt;/p&gt;

&lt;p&gt;Generating xlsx on the client&lt;/p&gt;

&lt;p&gt;Originally I used SheetJS. It writes a valid workbook, it is well documented, and the community build is free.&lt;/p&gt;

&lt;p&gt;What the community build will not do is cell styling. No bold headers, no fills, no borders. You can set column widths, number formats and autofilter, and that is where it stops.&lt;/p&gt;

&lt;p&gt;For a while that was fine. Then I looked at the output the way a user would and it was a grid of unformatted text with 18.4 in a column that should read $18.40. Technically correct, and it looked like a data dump rather than something you hand to an accountant.&lt;/p&gt;

&lt;p&gt;I swapped to ExcelJS. It is roughly the same payload, it supports real styling, and it took an afternoon. Now the export has a header row, banded rows, currency formatting, a frozen header, an autofilter, and a second sheet with totals by category.&lt;/p&gt;

&lt;p&gt;One detail worth passing on: write dates as real Date objects with a numFmt, not as strings. Text dates sort alphabetically, which means 01/05 sorts before 12/31/2025. If your output is someone's year of expenses, that quietly corrupts their ordering.&lt;/p&gt;

&lt;p&gt;And parse YYYY-MM-DD into a local date rather than letting the default constructor treat it as UTC, or every date renders a day early for anyone west of Greenwich.&lt;/p&gt;

&lt;p&gt;Shipping as a single HTML file&lt;/p&gt;

&lt;p&gt;The whole thing is one HTML file. Style inlined, script inlined, libraries from a CDN. You download it, double click it, and it runs.&lt;/p&gt;

&lt;p&gt;What that buys:&lt;/p&gt;

&lt;p&gt;The privacy claim is checkable. Anyone can open the file in a text editor and read what it does. Anyone can run it with the network tab open and watch nothing leave. That is a stronger statement than a privacy policy, because it does not require trusting me.&lt;/p&gt;

&lt;p&gt;It works offline after first load.&lt;/p&gt;

&lt;p&gt;There is no backend to secure, no database to breach, no account system to get wrong, and no subscription to cancel.&lt;/p&gt;

&lt;p&gt;What it costs:&lt;/p&gt;

&lt;p&gt;No sync, no multi-device, no server-side processing for anything heavy. Every constraint of the browser is your constraint.&lt;/p&gt;

&lt;p&gt;The file must stay small enough to be readable by a human who wants to check it, which rules out a lot of convenient dependencies.&lt;/p&gt;

&lt;p&gt;The part I would do the same way again&lt;/p&gt;

&lt;p&gt;Everything runs locally, which means you can verify it rather than believe it. Open devtools, watch the network tab, drop a receipt in. Nothing goes out.&lt;/p&gt;

&lt;p&gt;That is not a policy. It is just how it is built, and it is the only version of a privacy claim I would be comfortable making.&lt;/p&gt;

&lt;p&gt;I build DropSheet, which is the tool described above. It converts receipt photos and PDFs into a spreadsheet, entirely in the browser.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>privacy</category>
      <category>showdev</category>
    </item>
  </channel>
</rss>
