<?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: venn</title>
    <description>The latest articles on DEV Community by venn (@venn).</description>
    <link>https://dev.to/venn</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%2F4213372%2F90813bff-b21f-49bc-979e-f95570cd665f.png</url>
      <title>DEV Community: venn</title>
      <link>https://dev.to/venn</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/venn"/>
    <language>en</language>
    <item>
      <title>Detecting two-column resumes in the browser with pdf.js</title>
      <dc:creator>venn</dc:creator>
      <pubDate>Tue, 24 Nov 2026 04:04:53 +0000</pubDate>
      <link>https://dev.to/venn/detecting-two-column-resumes-in-the-browser-with-pdfjs-30di</link>
      <guid>https://dev.to/venn/detecting-two-column-resumes-in-the-browser-with-pdfjs-30di</guid>
      <description>&lt;p&gt;A lot of resume advice says "don't use two columns, the ATS can't read them." That's mostly true, but it's hard to &lt;em&gt;show&lt;/em&gt; someone. Their PDF looks fine on screen. So while building a small in-browser resume checker, I wanted to answer two concrete questions:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Does this PDF actually have a side column?&lt;/li&gt;
&lt;li&gt;What would a naive parser produce from it?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Everything below runs client-side. The file never leaves the browser.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: get positioned text out of the PDF
&lt;/h2&gt;

&lt;p&gt;pdf.js gives you text items with a transform matrix. The last two numbers are the x/y position (PDF coordinates, so y grows upward):&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="n"&gt;page&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;pdf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getPage&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&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="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;width&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;height&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getViewport&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;scale&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="p"&gt;}&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="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;items&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getTextContent&lt;/span&gt;&lt;span class="p"&gt;(&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="n"&gt;words&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;items&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;it&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;it&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;str&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;trim&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;it&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;str&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;it&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;str&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;it&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;transform&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="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;it&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;transform&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="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;it&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;width&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;h&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;it&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;height&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&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;h2&gt;
  
  
  Step 2: what a naive parser sees
&lt;/h2&gt;

&lt;p&gt;The simplest way to turn that into text is to sort top-to-bottom, then left-to-right, and glue items that share a baseline into one line:&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="n"&gt;sorted&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;words&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;slice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sort&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;x&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;On a one-column resume this works. On a two-column one it reads &lt;em&gt;straight across the page&lt;/em&gt;, so a line from your Skills sidebar ends up glued to a line from your job history:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;HubSpot      Grew organic signups 38% in 12 months
Google Ads   Responsible for social media.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That is the failure people warn about, and it's exactly what I show users. Seeing their own lines mixed up makes the point far better than a warning.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: find the gutter
&lt;/h2&gt;

&lt;p&gt;To detect a column split, I scan vertical lines across the middle of the page (from 15% to 85% of the text's width, every 2pt). For each x position I count how many characters belong to text items that &lt;em&gt;cross&lt;/em&gt; it. A real gutter is a run of x positions where almost nothing crosses:&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="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;minX&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;span&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mf"&gt;0.15&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="n"&gt;minX&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;span&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mf"&gt;0.85&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="o"&gt;+=&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;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;crossing&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&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="n"&gt;it&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="n"&gt;words&lt;/span&gt;&lt;span class="p"&gt;)&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="n"&gt;it&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;it&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;it&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;w&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;crossing&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;it&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;str&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;trim&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt;&lt;span class="p"&gt;;&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="n"&gt;crossing&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="n"&gt;totalChars&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mf"&gt;0.01&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="cm"&gt;/* extend or start an empty run */&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="cm"&gt;/* close the run */&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;I allow 1% because a single long heading or a horizontal rule label often spans the whole page. Then I try the widest empty run first and take its midpoint as the split.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 4: reject the false positives
&lt;/h2&gt;

&lt;p&gt;An empty vertical strip doesn't always mean two columns. The common false positive is a normal one-column resume with dates right-aligned:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Marketing Manager                     Mar 2021 – Present
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There's a big gap between the title and the date, so the gap looks like a gutter. Three checks filter these out. Each side must:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;have at least 4 lines and 20 words,&lt;/li&gt;
&lt;li&gt;be mostly not dates or short locations (fewer than half its lines can be date-ish),&lt;/li&gt;
&lt;li&gt;sit &lt;em&gt;beside&lt;/em&gt; the other side: I bucket y positions into 6pt bands, and at least 30% of the bands must have text on both sides.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The date filter is the one that matters most. Without it, almost every resume with right-aligned dates gets flagged.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 5: read it in a sensible order
&lt;/h2&gt;

&lt;p&gt;Once a split is accepted, the side with more characters is treated as the main column and read first, then the sidebar. That reading order is used for the rest of the checks (section detection, contact info, and so on), and also for the "fixed" one-column file the user can download.&lt;/p&gt;

&lt;h2&gt;
  
  
  DOCX is easier and harder
&lt;/h2&gt;

&lt;p&gt;For Word files I unzip the package and read the XML directly. Layout problems are explicit there: &lt;code&gt;w:cols&lt;/code&gt; with &lt;code&gt;num &amp;gt; 1&lt;/code&gt; means Word columns, a table holding most of the text means a layout table, and text boxes and header/footer parts are separate elements. It's easier to detect than PDF, but it turns up more ways to hide text, like contact details that only exist in the page header, which some parsers skip.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I learned
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Showing the mixed-up text beats any explanation.&lt;/li&gt;
&lt;li&gt;Most of the work is in rejecting false positives, not in finding the gutter.&lt;/li&gt;
&lt;li&gt;Keep the rules fixed and the scoring visible. The same file should always get the same result, and users should be able to see why.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you want to try it on your own resume, it's at &lt;a href="https://atsresumechecker.app" rel="noopener noreferrer"&gt;atsresumechecker.app&lt;/a&gt;. It's free and runs in the browser. I'd love to hear about PDFs that break the column detection.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;I used AI to help write this post. The approach and the code are from the actual project.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>pdf</category>
      <category>webdev</category>
      <category>showdev</category>
    </item>
    <item>
      <title>Building a Poople Solver: The Search Was Easy, the Word List Was Not</title>
      <dc:creator>venn</dc:creator>
      <pubDate>Tue, 24 Nov 2026 03:57:46 +0000</pubDate>
      <link>https://dev.to/venn/building-a-poople-solver-the-search-was-easy-the-word-list-was-not-5e0g</link>
      <guid>https://dev.to/venn/building-a-poople-solver-the-search-was-easy-the-word-list-was-not-5e0g</guid>
      <description>&lt;p&gt;&lt;a href="https://poople.io" rel="noopener noreferrer"&gt;Poople&lt;/a&gt; is a daily word puzzle. You get a four-letter start word and change one letter at a time until you reach POOP. Every guess has to be a real word, and fewer steps is better.&lt;/p&gt;

&lt;p&gt;I built a &lt;a href="https://hintra.io/poople-solver" rel="noopener noreferrer"&gt;Poople solver&lt;/a&gt; that finds the shortest path from any start word. The search code is short. Getting the word list right was the hard part.&lt;/p&gt;

&lt;h2&gt;
  
  
  Words as a map
&lt;/h2&gt;

&lt;p&gt;Think of every four-letter word as a stop on a map. Two words are connected when they differ by exactly one letter in the same spot. JUGS connects to BUGS. BUGS connects to BOGS.&lt;/p&gt;

&lt;p&gt;Solving a puzzle means finding the shortest route on this map to POOP.&lt;/p&gt;

&lt;h2&gt;
  
  
  Start from the finish line
&lt;/h2&gt;

&lt;p&gt;Every puzzle ends at POOP. So instead of searching from each start word, I search once, outward from POOP. First all words one step away, then all words two steps away, and so on. This is called a breadth-first search.&lt;/p&gt;

&lt;p&gt;When it finishes, I know how far every word is from POOP. Solving any start word is then just a lookup.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;collections&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;deque&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;neighbors&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;word&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;words&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&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="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="s2"&gt;"abcdefghijklmnopqrstuvwxyz"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;cand&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;word&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;word&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;cand&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="n"&gt;word&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;cand&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;words&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="k"&gt;yield&lt;/span&gt; &lt;span class="n"&gt;cand&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;distances&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;words&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"poop"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;dist&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="n"&gt;queue&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;deque&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;queue&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;w&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;queue&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;popleft&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;neighbors&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;words&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;dist&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;dist&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;dist&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
                &lt;span class="n"&gt;queue&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;dist&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To get the actual path, start at your word and keep stepping to any neighbor that is one step closer to POOP.&lt;/p&gt;

&lt;h2&gt;
  
  
  When there is more than one shortest path
&lt;/h2&gt;

&lt;p&gt;JUGS (puzzle #464) has three 5-step paths:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;JUGS → BUGS → BOGS → BOOS → BOOP → POOP&lt;/li&gt;
&lt;li&gt;JUGS → JOGS → COGS → COOS → COOP → POOP&lt;/li&gt;
&lt;li&gt;JUGS → JOGS → BOGS → BOOS → BOOP → POOP&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All three score the same, but people find some easier to follow than others. So for each path I look at its least common word. The more familiar that word is, the higher the path goes in the list. The word list is sorted by how often each word shows up in movie subtitles, which works well as a "would a normal person know this word" score.&lt;/p&gt;

&lt;h2&gt;
  
  
  The hard part: which words does the game accept?
&lt;/h2&gt;

&lt;p&gt;The code above only works if the word list matches the game. That turned out to be the real problem.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A big list is too loose.&lt;/strong&gt; ENABLE, a free word list used by many word games, has 3,903 four-letter words. Many of them are words almost nobody uses. When I tried some in the game, it rejected AITS, ANTA, ARES and SIMS.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A small list is too strict.&lt;/strong&gt; So I kept only the 2,303 words that are in both ENABLE and a standard-size English dictionary. That removed the junk, but it also removed words the game does accept.&lt;/p&gt;

&lt;p&gt;Puzzle #465 showed the problem. The start word was ANTI. My solver said the best path was 10 steps. The game said 8.&lt;/p&gt;

&lt;p&gt;Playing it in the game found the gap: it accepts ANDS and BODS, and my list had dropped both. With those two words back in, the solver finds the same 8-step path:&lt;/p&gt;

&lt;p&gt;ANTI → ANTS → ANDS → AIDS → BIDS → BODS → BOOS → BOOP → POOP&lt;/p&gt;

&lt;p&gt;The next day the game showed this exact path as its own answer.&lt;/p&gt;

&lt;h2&gt;
  
  
  Two small files fix most of it
&lt;/h2&gt;

&lt;p&gt;There is no public list of the words Poople accepts, so I keep two plain text files:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;added.txt&lt;/code&gt;: words the game accepted that my list missed (BOOP, ANDS, BODS so far)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;rejected.txt&lt;/code&gt;: words the game turned down (AITS, ANTA, ARES, SIMS)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each day I compare my answer with the game's best score. If the game wins, I find the missing word and add it. Each fix makes the next day a bit more accurate.&lt;/p&gt;

&lt;h2&gt;
  
  
  A few numbers from the map
&lt;/h2&gt;

&lt;p&gt;Using my list of 2,303 words:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;2,166 words can reach POOP. The other 136 have no path at all.&lt;/li&gt;
&lt;li&gt;About 4 in 5 reachable words need 4 to 6 steps.&lt;/li&gt;
&lt;li&gt;ANTI needed 8 steps, more than 96% of possible start words.&lt;/li&gt;
&lt;li&gt;The farthest word is OBIT, at 12 steps.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Runs in the browser
&lt;/h2&gt;

&lt;p&gt;2,300 short words is a small file, so the whole solver runs in the page. Nothing is sent to a server, and the word you type never leaves your device.&lt;/p&gt;

&lt;p&gt;That also made a hint mode easy. "Next step only" shows just the next word and how many steps are left, for people who want a nudge rather than the full answer.&lt;/p&gt;

&lt;h2&gt;
  
  
  Try it
&lt;/h2&gt;

&lt;p&gt;The &lt;a href="https://hintra.io/poople-solver" rel="noopener noreferrer"&gt;Poople solver&lt;/a&gt; is free and needs no sign-up. If you want to know how we check each day's answer against the game, it is written up in &lt;a href="https://hintra.io/how-poople-works" rel="noopener noreferrer"&gt;How we work out Poople answers&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;If you have built something similar, I would like to hear how you handled the word list.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;This post was written with help from AI.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>showdev</category>
      <category>python</category>
      <category>algorithms</category>
    </item>
    <item>
      <title>Twitter Video to GIF: 4 Tools Compared (One Is Mine)</title>
      <dc:creator>venn</dc:creator>
      <pubDate>Tue, 24 Nov 2026 03:54:27 +0000</pubDate>
      <link>https://dev.to/venn/twitter-video-to-gif-4-tools-compared-one-is-mine-3pfh</link>
      <guid>https://dev.to/venn/twitter-video-to-gif-4-tools-compared-one-is-mine-3pfh</guid>
      <description>&lt;p&gt;When you save a GIF from X (Twitter), you usually get an MP4 video, not a GIF. X stores every GIF as a video. That's fine on your phone, but it doesn't work when a chat app, a doc or a forum wants an actual &lt;code&gt;.gif&lt;/code&gt; image.&lt;/p&gt;

&lt;p&gt;I built one of the tools that fixes this, &lt;a href="https://twittergif.com/" rel="noopener noreferrer"&gt;TwitterGIF&lt;/a&gt;, so I'm biased. To be fair about it, I also tried three other tools with the same post. Here is what I found, including where the other tools beat mine.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Checked in November 2026. These tools change often, so check their own pages too.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The short answer
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Free, no watermark, fewest steps:&lt;/strong&gt; Twitee (it converts the whole clip)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Free, no watermark, and you want to trim, crop or add text:&lt;/strong&gt; useSignal&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;You already have the MP4 file:&lt;/strong&gt; ezgif&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;You want to trim and see the file size on one screen, or need HD, long clips or batches:&lt;/strong&gt; TwitterGIF (free has a small watermark; paid plans remove it)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Side by side
&lt;/h2&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;TwitterGIF&lt;/th&gt;
&lt;th&gt;Twitee&lt;/th&gt;
&lt;th&gt;useSignal&lt;/th&gt;
&lt;th&gt;ezgif&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Paste a post link&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;No, needs the video file&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Price&lt;/td&gt;
&lt;td&gt;Free 5 GIFs/day; paid from $1.99 once&lt;/td&gt;
&lt;td&gt;Free&lt;/td&gt;
&lt;td&gt;Free&lt;/td&gt;
&lt;td&gt;Free&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Watermark&lt;/td&gt;
&lt;td&gt;Small one on free GIFs&lt;/td&gt;
&lt;td&gt;None&lt;/td&gt;
&lt;td&gt;None&lt;/td&gt;
&lt;td&gt;None&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Trim the clip&lt;/td&gt;
&lt;td&gt;Yes, on the same screen&lt;/td&gt;
&lt;td&gt;No, it converts the whole clip&lt;/td&gt;
&lt;td&gt;Yes, in a full editor&lt;/td&gt;
&lt;td&gt;Yes, start and end times&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;File size before you save&lt;/td&gt;
&lt;td&gt;Live estimate as you change settings&lt;/td&gt;
&lt;td&gt;Shown after converting&lt;/td&gt;
&lt;td&gt;Estimate before export&lt;/td&gt;
&lt;td&gt;Shown after converting&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Where the video is processed&lt;/td&gt;
&lt;td&gt;Your browser&lt;/td&gt;
&lt;td&gt;Your browser&lt;/td&gt;
&lt;td&gt;Your browser&lt;/td&gt;
&lt;td&gt;Their server by default&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Ads&lt;/td&gt;
&lt;td&gt;None&lt;/td&gt;
&lt;td&gt;None (per its FAQ)&lt;/td&gt;
&lt;td&gt;No third-party ads I saw&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  TwitterGIF (mine)
&lt;/h2&gt;

&lt;p&gt;Paste the post link, drag the handles to pick the part you want, choose the frame rate and width, and the estimated GIF size updates as you go. Everything happens in your browser, so the video is never uploaded.&lt;/p&gt;

&lt;p&gt;What to know:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Free: 5 GIFs a day, clips up to 30 seconds, 480px, 15 fps, with a small watermark in the corner.&lt;/li&gt;
&lt;li&gt;Paid removes the watermark and allows clips up to 10 minutes: GIF Mini is $1.99 for 5 GIFs, GIF Pack is $4.99 for 100 (one-time, no expiry). Pro is unlimited and adds 1080px and converting 10 links at once.&lt;/li&gt;
&lt;li&gt;If you just need one clean GIF for free, the next two tools will do that.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Twitee
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://twitee.co/twitter-gif-downloader" rel="noopener noreferrer"&gt;Twitee&lt;/a&gt; is the simplest free option. Paste a link, pick a quality (Best, High, Medium or Low) and save a real &lt;code&gt;.gif&lt;/code&gt;. Its page says it's free with no watermark, no limit and no ads, and that the GIF is made on your device. If a post has several clips, or quotes another post with a video, it lists them all.&lt;/p&gt;

&lt;p&gt;What to know:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It converts the whole clip. You can't trim, so a long video makes a big, slow GIF.&lt;/li&gt;
&lt;li&gt;When I tried it, a "verify you are human" check came up before it fetched the post. (TwitterGIF's free plan has a similar check.)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  useSignal
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://www.usesignal.dev/tools/video-downloader/twitter-video-to-gif" rel="noopener noreferrer"&gt;useSignal&lt;/a&gt; finds the video, then opens it in a full video editor in your browser. You can trim, crop, change speed and add text, then export a GIF at 10–24 fps and 320–800px wide. No watermark and no limit on how many you make.&lt;/p&gt;

&lt;p&gt;What to know:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It's more steps than the others, but it's the most flexible free choice.&lt;/li&gt;
&lt;li&gt;In my test, a 5-second vertical clip at 480×852 came out at 16.5 MB. Its estimate before export said about 9 MB. That's normal for GIFs of real video (see the tips below).&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  ezgif
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://ezgif.com/video-to-gif" rel="noopener noreferrer"&gt;ezgif&lt;/a&gt; is the classic GIF toolbox, with resize, crop, optimize and text tools. It doesn't read post links: when I pasted one, it returned an error. You first have to save the MP4 from X with another tool, then upload it.&lt;/p&gt;

&lt;p&gt;What to know:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Files go to their server unless you tick "Local processing."&lt;/li&gt;
&lt;li&gt;The page has ads.&lt;/li&gt;
&lt;li&gt;Longer clips need lower frame rates (for example, 30 seconds max at 10 fps).&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Tips for a GIF that isn't huge
&lt;/h2&gt;

&lt;p&gt;GIF is an old format, so video clips get big fast. A few things help:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Keep it short.&lt;/strong&gt; 2 to 6 seconds is enough for most reactions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;480px wide is plenty&lt;/strong&gt; for chat apps. Go bigger only if people will see it full screen.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;10 to 15 fps&lt;/strong&gt; looks smooth enough and keeps the file small. 30 fps can double the size.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;It can't be sharper than the post.&lt;/strong&gt; A blurry original stays blurry.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;GIFs have no sound.&lt;/strong&gt; If you need audio, save the MP4 instead.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Only public posts work.&lt;/strong&gt; None of these tools can get video from protected accounts or deleted posts.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Can I convert a Twitter video to GIF without a watermark for free?&lt;/strong&gt;&lt;br&gt;
Yes. Twitee and useSignal add no watermark and cost nothing. TwitterGIF's free GIFs have a small watermark; its paid plans remove it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How do I do it on an iPhone?&lt;/strong&gt;&lt;br&gt;
In the X app, tap Share on the post and choose Copy link. Open TwitterGIF, Twitee or useSignal in Safari, paste the link and convert. Downloads usually land in the Files app, in Downloads.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why does X give me an MP4 when I save a GIF?&lt;/strong&gt;&lt;br&gt;
X turns every uploaded GIF into a short looping video, which is much smaller. These tools turn it back into a real GIF file.&lt;/p&gt;




&lt;p&gt;If you try TwitterGIF and something breaks, like an odd post, a quote post or a clip that won't load, tell me in the comments. I read every one.&lt;/p&gt;

</description>
      <category>showdev</category>
      <category>tools</category>
      <category>productivity</category>
      <category>twitter</category>
    </item>
    <item>
      <title>Convert Twitter (X) Videos to GIF in the Browser with ffmpeg.wasm</title>
      <dc:creator>venn</dc:creator>
      <pubDate>Wed, 28 Oct 2026 15:32:42 +0000</pubDate>
      <link>https://dev.to/venn/convert-twitter-x-videos-to-gif-in-the-browser-with-ffmpegwasm-1pci</link>
      <guid>https://dev.to/venn/convert-twitter-x-videos-to-gif-in-the-browser-with-ffmpegwasm-1pci</guid>
      <description>&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A tiny server finds the MP4 behind a tweet; the browser downloads it straight from X.&lt;/li&gt;
&lt;li&gt;ffmpeg.wasm turns it into a GIF on the visitor's device, so nothing is uploaded.&lt;/li&gt;
&lt;li&gt;The tricks that mattered: load ffmpeg only on click, build a custom 256-color palette, and watch memory on phones.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I often want to turn a short clip from X (Twitter) into a GIF — for a reply, a doc, or a chat. Most online converters make you sign up or upload the video to their server, then hand back a blurry file.&lt;/p&gt;

&lt;p&gt;So I built one that does the whole job inside the browser tab. Here is how it works, and the things that tripped me up, in case you want to do something similar.&lt;/p&gt;

&lt;h2&gt;
  
  
  The plan in one sentence
&lt;/h2&gt;

&lt;p&gt;Find the video file behind the tweet, download it straight into the browser, and let ffmpeg (compiled to WebAssembly) turn it into a GIF on the visitor's own device.&lt;/p&gt;

&lt;p&gt;That gives three nice properties:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Nothing is uploaded.&lt;/strong&gt; The video goes from X to the visitor's tab, not to my server.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The server stays tiny.&lt;/strong&gt; It only answers one question: "which video file belongs to this tweet?"&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No account needed.&lt;/strong&gt; There is nothing to store, so there is nothing to log in to.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Step 1: Find the video file behind a tweet
&lt;/h2&gt;

&lt;p&gt;A tweet link like &lt;code&gt;x.com/user/status/123…&lt;/code&gt; doesn't point at a video file. I run a small Cloudflare Worker that takes the tweet ID and returns the list of MP4 files X has for it (X keeps several sizes of each video).&lt;/p&gt;

&lt;p&gt;The browser then downloads the MP4 directly from &lt;code&gt;video.twimg.com&lt;/code&gt;. That works because X's video server allows other websites to fetch its files (it sends CORS headers), so the video never passes through my server.&lt;/p&gt;

&lt;p&gt;One easy win: &lt;strong&gt;download the smallest version that is still wide enough for the GIF.&lt;/strong&gt; If the GIF will be 480px wide, there is no point fetching the 1280px file — it's much bigger and only makes people wait.&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;// Smallest video version that is at least as wide as the GIF&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;pickVariant&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;variants&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;gifWidth&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;byWidth&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[...&lt;/span&gt;&lt;span class="nx"&gt;variants&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;sort&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;width&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;width&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;byWidth&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&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="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;v&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;width&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="nx"&gt;gifWidth&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="nx"&gt;byWidth&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;at&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&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;h2&gt;
  
  
  Step 2: Load ffmpeg.wasm only when someone clicks "Convert"
&lt;/h2&gt;

&lt;p&gt;The ffmpeg engine is big — about 32 MB before compression. Loading it with the page would make the site slow for everyone, including people who only came to read.&lt;/p&gt;

&lt;p&gt;So the engine loads &lt;strong&gt;only after the first click on "Convert"&lt;/strong&gt;, with a progress bar while it downloads. After that it stays in memory, so the second GIF starts instantly.&lt;/p&gt;

&lt;p&gt;Two gotchas here:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;ffmpeg runs in a background thread (a Web Worker), and that thread refuses to load code from another domain.&lt;/strong&gt; The fix: download the core files from the CDN yourself, turn them into local &lt;code&gt;blob:&lt;/code&gt; URLs, and hand those to ffmpeg. I also keep a second CDN as a backup in case the first one is blocked.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The faster multi-threaded build needs two extra security headers on your page&lt;/strong&gt; (COOP and COEP). On my site those headers broke the Cloudflare Turnstile anti-bot check, so I use the single-thread build. It's slower but works everywhere. If your page has no third-party embeds, try multi-thread first and fall back when it fails.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;FFmpeg&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@ffmpeg/ffmpeg&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;toBlobURL&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@ffmpeg/util&lt;/span&gt;&lt;span class="dl"&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;base&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;https://cdn.jsdelivr.net/npm/@ffmpeg/core@0.12.10/dist/esm&lt;/span&gt;&lt;span class="dl"&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;ffmpeg&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;FFmpeg&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;ffmpeg&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;load&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;coreURL&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;toBlobURL&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;base&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;/ffmpeg-core.js`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;text/javascript&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
  &lt;span class="na"&gt;wasmURL&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;toBlobURL&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;base&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;/ffmpeg-core.wasm`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;application/wasm&lt;/span&gt;&lt;span class="dl"&gt;'&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;h2&gt;
  
  
  Step 3: The ffmpeg command that makes GIFs look good
&lt;/h2&gt;

&lt;p&gt;A GIF can only use 256 colors. If you let ffmpeg pick a generic palette, the result looks grainy. The well-known fix is to &lt;strong&gt;build a palette from the clip itself, then use it&lt;/strong&gt; — and you can do both in one command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nt"&gt;-ss&lt;/span&gt; 3 &lt;span class="nt"&gt;-t&lt;/span&gt; 5 &lt;span class="nt"&gt;-i&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt;.mp4
&lt;span class="nt"&gt;-filter_complex&lt;/span&gt; &lt;span class="s2"&gt;"fps=15,scale=480:-1:flags=lanczos,split[a][b];[a]palettegen[p];[b][p]paletteuse=dither=bayer:bayer_scale=5:diff_mode=rectangle"&lt;/span&gt;
&lt;span class="nt"&gt;-loop&lt;/span&gt; 0 out.gif
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What each part does, in plain words:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;-ss 3 -t 5&lt;/code&gt; &lt;strong&gt;before&lt;/strong&gt; &lt;code&gt;-i&lt;/code&gt;: jump straight to second 3 and read only 5 seconds, instead of decoding the whole video.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;fps=15&lt;/code&gt; then &lt;code&gt;scale=480:-1&lt;/code&gt;: drop frames first, then resize — so we don't waste time resizing frames we throw away. &lt;code&gt;-1&lt;/code&gt; keeps the aspect ratio, and &lt;code&gt;flags=lanczos&lt;/code&gt; is a sharper way to shrink images.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;split&lt;/code&gt; → &lt;code&gt;palettegen&lt;/code&gt; → &lt;code&gt;paletteuse&lt;/code&gt;: one copy of the frames is used to pick the best 256 colors, the other copy is drawn with them.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;dither=bayer&lt;/code&gt;: a fixed dot pattern instead of the default "noisy" dithering. The noise changes every frame, which makes GIFs much bigger. Bayer stays still, so files shrink a lot.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;diff_mode=rectangle&lt;/code&gt;: only redraw the part of each frame that changed.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;-loop 0&lt;/code&gt;: loop forever, like people expect from a GIF.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Step 4: Don't crash the tab
&lt;/h2&gt;

&lt;p&gt;Everything runs in the visitor's memory, and phones don't have much. Three things helped:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Limit the source size.&lt;/strong&gt; ffmpeg.wasm keeps the whole video in memory, so I stop the download once a file passes 450 MB. Above that, phone tabs started crashing.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Switch to two passes for long or large clips.&lt;/strong&gt; The one-command version keeps every frame in memory until the palette is ready. When the raw frames would pass ~256 MB, I first save the palette to a PNG, then run a second pass that uses it. Slower, but memory stays flat.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Give ffmpeg a copy of the file.&lt;/strong&gt; &lt;code&gt;ffmpeg.writeFile()&lt;/code&gt; moves the buffer into the worker, and your original becomes empty. If the user tweaks the settings and converts again, you need the original — so pass &lt;code&gt;data.slice()&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Step 5: Tell people what's happening
&lt;/h2&gt;

&lt;p&gt;A blank spinner for 20 seconds feels broken. Two small touches made it feel fast:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Real progress.&lt;/strong&gt; ffmpeg prints lines like &lt;code&gt;time=00:00:02.40&lt;/code&gt; while it works. Divide that by the clip length and you have a progress bar.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A size estimate before converting.&lt;/strong&gt; I converted a bunch of real tweet videos and found a 5-second, 480px, 15 fps clip usually lands between 1.3 MB (still shots) and 5.2 MB (shaky phone video), about 2.6 MB in the middle. From that I show a live "about X MB" as people drag the sliders, so nobody waits for a 40 MB file by accident.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What I'd tell myself before starting
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Start with the ffmpeg command on your laptop.&lt;/strong&gt; Get the GIF looking right in the terminal first; moving it to the browser is the easy part.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Load the engine lazily.&lt;/strong&gt; 30+ MB is too much for a page load.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Plan for memory, not just speed.&lt;/strong&gt; Crashes on phones were a bigger problem than slow conversions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Check which file you download.&lt;/strong&gt; Picking the right video size saved more time than any ffmpeg flag.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you want to see it working, the tool is at &lt;a href="https://twittergif.com" rel="noopener noreferrer"&gt;twittergif.com&lt;/a&gt; — paste a post link, trim the clip, and the GIF is made in your tab.&lt;/p&gt;

&lt;p&gt;Questions or a better ffmpeg filter? I'd love to hear it in the comments.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>webassembly</category>
      <category>ffmpeg</category>
    </item>
  </channel>
</rss>
