Typefully

Bitcoin Ordinals: Saving with SVGZ

Avatar

Share

 • 

2 years ago

 • 

View on X

Bitcoin Ordinals: A Way to Save 50-80% When Inscribing SVGs Four days ago, I posted an idea: would it be feasible to inscribe compressed SVG files (SVGZ) for a savings of 60-70% (or more)? As of yesterday, I have the answer... ⬇️ twitter.com/TheBenMeadows/status/1708990258631917955
Before we get into the details, here's a quick overview of why you would want to use an SVGZ vs an SVG. Simply because an SVGZ is generally 50-80% smaller than the SVG file that it is based on. However, viewing an SVGZ isn't always a simple task.
Why? Because generally, the browser doesn't know that it's a compressed (or zipped) SVG. So, when you try and view the file, you get something like this.
You can see this here, if you look at the first SVGZ file that I inscribed. ord.io/34963011
The solution I came up with was to use JavaScript to decompress the SVGZ and then display it in the browser as an SVG. This turned out to be harder than it sounds.
I started by using the pako library, which @boppleton had already inscribed here (thanks to @pryzmxbt for the heads up). ord.io/24777592
After fiddling around with the formatting of the uncompressed SVG, I finally got the logic right and inscribed a recursive edition. When looking at the inscription on Ordinals.com (and @magiceden), everything looked great. ordinals.com/inscription/0d6220b1cbf23369204a78f2de4442e755a86ae98a4d6202750da7494ac4259ei0
However, when I checked @ord_io and @trygamma, the image wasn't displaying at all. What was going on? Essentially, those two websites have stricter CSP policies that weren't allowing the decompression logic to run. ord.io/35084623
So, I went back to the drawing board and refactored the code (several times). Eventually, I came up with a method that worked across all major Ordinals sites and wallets.
Here is the working test inscription. The image is (part of) a collab between @Twickert_ and me and will be used in an upcoming release. ord.io/35118062
Why is this significant? Because you can now inscribe vector images that are 50-80% smaller. The test SVG was 107 KB - the SVGZ is 32 KB. This means that you can either save a significant amount when inscribing art or inscribe more detailed art!
How did I get the SVG down to 107 KB in the first place (when the original image was a PNG several times that size)? That's a post for another time. I have done compression work for multiple artists and projects in Web3.
I have also been experimenting with some other interesting capabilities involving SVGZ files and Ordinals, but I'll save that for a future post.
If you are interested in having me help you or your project with art compression or other technical aspects involving blockchain (ETH or BTC), feel free to contact me here or at thebenmeadows.com.
Bonus: After giving it the relevant information, I asked ChatGPT to write a poem based on my experience and struggles with this project.
Avatar

͏ ͏ ͏

@TheBenMeadows

Entrepreneur ⬩ Artist ⬩ Technologist