Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Image Composition #4276

Open
lifofifoX opened this issue Mar 13, 2025 · 8 comments
Open

Image Composition #4276

lifofifoX opened this issue Mar 13, 2025 · 8 comments

Comments

@lifofifoX
Copy link
Collaborator

One of the primary things many use recursion for is composing images in the browser with the Canvas API. The purist in me dies a little every time I see an HTML page pretending to be an image.

I've always wondered if basic image composition could be supported by the ord server. Previously, I discarded the idea, assuming it was probably too complex. And maybe it still is.

But ordinals have grown significantly since recursion was first introduced, both in terms of complexity and recursive endpoints. So perhaps this idea is worth revisiting.

Considering that maybe 90–95% of recursive inscriptions are for composing images in the browser, should the ordinals protocol add support for image composition in some capacity? Maybe a post 1.0 feature?

@lifofifoX
Copy link
Collaborator Author

Here's a simple implementation idea with backward compatibility:

Introduce a new odd tag representing an ordered list of inscription ID layers along with the intended content type. For backward compatibility, the primary content type would still be HTML, with relevant HTML as the content.

A new content endpoint, say /compose/<id>, could use data from this ordered list to serve a permanently cacheable image with the intended content type.

@lifofifoX
Copy link
Collaborator Author

lifofifoX commented Mar 14, 2025

Other possible use for composition could be splitting larger files into multiple inscriptions, and have the ord server automatically stitch them together.

@bruffstar
Copy link

Although I do agree, on the face of it, it is strange to see HTML inscriptions "pretending" to be images, however, I would opt to embrace this, HTML inscriptions are a gift on ordinals compared to other chains. When we did Pizza Ninjas, it started off as just layering in the canvas, but then we got wild with it and it became a real showcase for recursion and what can be possible with digital collectables on Bitcoin. I would encourage anyone creating recursive collections to go one step further and do some cool features with the HTML/JS.

Finding a cool way of standardizing the caching of the "thumbnail" of these inscriptions I can get behind though.

@lifofifoX
Copy link
Collaborator Author

My proposal wouldn't be a replacement for something like Pizza Ninjas. However, the overwhelming majority of recursion usage is HTML disguised as an image. That's a clear sign we're missing some standardization here.

@raphjaph
Copy link
Collaborator

I'm having a hard time seeing the concrete improvement. It's difficult to come with a scheme on how to exactly compose the images together (next to each other?, layered on top of each other?, in a grid?). HTML seems like the natural language that can capture all the ways you would want to compose images.

Additionally, we don't want to be doing composition on the server side because of DoS concerns. All composition should be done client side. You could emulate something like this by inscribing a javascript library that then composes images together?

@lifofifoX
Copy link
Collaborator Author

The improvements with some standardization here would be pretty significant. Explorers and CDNs can easily cache the recursive images and we'll no longer see that black screen of death + 1000s of fetch requests on page load. Images would also render natively as images (vs html page containing an image) on all platforms, making sure they display well on all screen sizes.

Layering on top of each other is probably the primary usage. But stitching them together is also an interesting use case, as a clear answer to the age-old question re: inscribing larger files.

If composing on the server side is a concern, I think some standardization would still be helpful as a starting point and allow building middleware layers for serving content.

@emilcondrea
Copy link
Contributor

While this looks like an interesting idea, image composition on demand is a good candidate for DoS. Yes, it can be cached, but while cache is computed it will eat a lot of server resources. The best tradeoff so far for pre-rendering html/heavy inscriptions as images is to do it async/outofband and store a thumbnail that can be cached.

@lifofifoX
Copy link
Collaborator Author

Concerns re: DoS seem rather misplaced to me. Server side image editing isn't some novel idea and has been around since the 90s. And DoS concerns can be worked around in many different ways.

That said, standardization even without any server side component would be very helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants