<?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: banggui</title>
    <description>The latest articles on DEV Community by banggui (@banggui_song_498de81f6a95).</description>
    <link>https://dev.to/banggui_song_498de81f6a95</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%2F4221142%2F0f03e37f-a4f7-4f87-abb2-8e8e21799924.png</url>
      <title>DEV Community: banggui</title>
      <link>https://dev.to/banggui_song_498de81f6a95</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/banggui_song_498de81f6a95"/>
    <language>en</language>
    <item>
      <title>Does PNG to ICO keep transparency? A measured alpha test at 16, 32 and 48 px</title>
      <dc:creator>banggui</dc:creator>
      <pubDate>Sun, 01 Nov 2026 20:13:07 +0000</pubDate>
      <link>https://dev.to/banggui_song_498de81f6a95/does-png-to-ico-transparency-survive-a-measured-alpha-test-across-16-128-px-58om</link>
      <guid>https://dev.to/banggui_song_498de81f6a95/does-png-to-ico-transparency-survive-a-measured-alpha-test-across-16-128-px-58om</guid>
      <description>&lt;h1&gt;
  
  
  Does PNG to ICO keep transparency? A measured alpha test at 16, 32 and 48 px
&lt;/h1&gt;

&lt;p&gt;Yes. A PNG with an alpha channel, converted to ICO, keeps alpha = 0 in every transparent pixel at all three sizes tested. Below is the pixel-by-pixel proof.&lt;/p&gt;

&lt;h2&gt;
  
  
  The question
&lt;/h2&gt;

&lt;p&gt;When you save an image as JPEG, the alpha channel is gone — JPEG has no transparency. If your icon source was a JPG, renaming the file extension to &lt;code&gt;.ico&lt;/code&gt; does not bring alpha back; the pixel data simply doesn't contain it.&lt;/p&gt;

&lt;p&gt;But if your source is a PNG with an alpha channel, does the ICO conversion preserve it? I ran a measurement to find out.&lt;/p&gt;

&lt;h2&gt;
  
  
  Source image
&lt;/h2&gt;

&lt;p&gt;A test PNG with a gradient alpha channel: at 16×16, every row steps through alpha values 0, 64, 128, 255 — four columns of each. The image has 64 fully transparent pixels (alpha = 0), 128 partially transparent pixels (alpha 64 and 128), and 64 fully opaque pixels (alpha = 255). At 32×32 the pattern scales up to 256/512/256. At 48×48 the anti-aliasing produces a richer distribution but the transparent count is 528.&lt;/p&gt;

&lt;p&gt;The ICO file produced from this PNG is 625 bytes total, containing three frames: 16×16 (138 bytes), 32×32 (151 bytes), 48×48 (282 bytes). Pillow independently decoded each PNG entry inside the ICO to verify the pixel data.&lt;/p&gt;

&lt;h2&gt;
  
  
  Method
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Open the PNG in the converter at &lt;a href="https://icoforge.com/png-to-ico-transparency-test" rel="noopener noreferrer"&gt;icoforge.com/png-to-ico-transparency-test&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Convert to ICO and download the output file.&lt;/li&gt;
&lt;li&gt;Decode each frame inside the ICO using Pillow's &lt;code&gt;Image.open()&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Count pixels at each alpha value: 0 (transparent), 1–254 (partially transparent), 255 (opaque).&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Results
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Size (px)&lt;/th&gt;
&lt;th&gt;Frame bytes&lt;/th&gt;
&lt;th&gt;Alpha 0 (transparent)&lt;/th&gt;
&lt;th&gt;Alpha 1–254 (partial)&lt;/th&gt;
&lt;th&gt;Alpha 255 (opaque)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;16&lt;/td&gt;
&lt;td&gt;138&lt;/td&gt;
&lt;td&gt;64&lt;/td&gt;
&lt;td&gt;128&lt;/td&gt;
&lt;td&gt;64&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;32&lt;/td&gt;
&lt;td&gt;151&lt;/td&gt;
&lt;td&gt;256&lt;/td&gt;
&lt;td&gt;512&lt;/td&gt;
&lt;td&gt;256&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;48&lt;/td&gt;
&lt;td&gt;282&lt;/td&gt;
&lt;td&gt;528&lt;/td&gt;
&lt;td&gt;1,248&lt;/td&gt;
&lt;td&gt;528&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;ICO total: 625 bytes. Source SHA-256: &lt;code&gt;a6286835afc613468120d32d780b3d954bfb5b85e983cc0ea845617b8eb04e7a&lt;/code&gt;. Output ICO SHA-256: &lt;code&gt;33d026fca2ea106d6e46b51c944f20531f16105dd40797b155295b1e56715903&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Every number in this table comes from the measurements at &lt;a href="https://icoforge.com/png-to-ico-transparency-test" rel="noopener noreferrer"&gt;icoforge.com/png-to-ico-transparency-test&lt;/a&gt;, where the source PNG and output ICO are also available for download.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why alpha = 0 at the transparent pixels means transparency survived
&lt;/h2&gt;

&lt;p&gt;The source PNG has 64 pixels at alpha = 0 in the 16×16 frame. If the ICO conversion had flattened the image — filling transparent areas with white or black — those pixels would show alpha = 255. Instead, the ICO frame contains exactly 64 pixels at alpha = 0, matching the source. The same holds at 32×32 (256 pixels at alpha 0) and 48×48 (528 pixels at alpha 0). The transparent regions are preserved.&lt;/p&gt;

&lt;p&gt;The partially transparent pixel counts also match: 128 at 16×16, 512 at 32×32, 1,248 at 48×48. These are the pixels where the source alpha is 64 or 128 — and the ICO preserves those intermediate values exactly.&lt;/p&gt;

&lt;h2&gt;
  
  
  What about JPEG sources?
&lt;/h2&gt;

&lt;p&gt;JPEG does not store an alpha channel. A JPG file contains only RGB data. If you convert a JPG to ICO, the result has no transparency — not because the converter dropped it, but because the source never had it. Changing a &lt;code&gt;.jpg&lt;/code&gt; filename to &lt;code&gt;.ico&lt;/code&gt; doesn't change the pixel data inside.&lt;/p&gt;

&lt;h2&gt;
  
  
  Data and sources
&lt;/h2&gt;

&lt;p&gt;All measurements were taken on 2026-10-26 using Chrome's canvas rendering pipeline and verified with Pillow. The raw measurements JSON is available at:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;/samples/png-alpha-test/measurements.json&lt;/code&gt; — frame byte counts, alpha value distributions, and SHA-256 hashes for source and output.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The source PNG and output ICO files are downloadable from the &lt;a href="https://icoforge.com/png-to-ico-transparency-test" rel="noopener noreferrer"&gt;PNG to ICO transparency test page&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;License: CC0 (public domain).&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>css</category>
      <category>performance</category>
    </item>
  </channel>
</rss>
