-
-
Notifications
You must be signed in to change notification settings - Fork 9.1k
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
Idea: embed drawing source code into the exported PNG #414
Comments
There's missing a mindblown reaction :p |
This is a clever idea |
@vjeux what do you mean? It's right there… |
@frantic what about a QR code? We could put it an a corner then remove it when importing the image. |
I made a try with QR Code here. |
@frantic I would prefer to add text metadata to the PNG. I have found https://github.com/mozilla/openbadges-backpack/wiki/badge-baking#baking which could be used to add metadata to the image. |
Maybe I'm missing something, but surely we don't want to be displaying a QR code in the corner of the exported images?
It's steganography, btw (I get it wrong all the time, too). And I'd not add anything to the bitmap, certainly not anything that visibly changes it. Even if it's done right, and isn't discernible by naked eye, it would likely prevent image optimizations etc. Thus, same as @giovannigiordano I believe the only way to go about this is metadata. But still, is it a good idea? It'll add KBs (potentially 50-100KB+ for complex scenes), unnecessarily for most use cases. Keep in mind that this would increase the payload when the images are embedded in blog posts etc. (without running them through an optimizer that strips metadata). On top of that, no one ever expects that a png file contains the original scene data, so we'd need to explain it. And on top of that, when someone wants to just save a scene file, they'd now need to bundle in hundreds of KBs of bitmap data in form of PNG alongside it? |
Maybe there can be a middle ground here. The metadata could only contain the public unique url of the drawing (new feature discussed here #409) Thus we would have the best of both world :
|
@lorisdev interesting idea, except the public urls are generated only manually. Moreoever, even if we decided to generate those urls on every canvas change, automatically, some users may not want to generate public urls at all (even if they're random). Also, the url generation, I reckon, takes some time, which means it'd potentially slow down the export (you'd click on export and need to wait until the url is generated) --- this would probably be the least problem, though. Also note that it'd not work if user isn't connected to the internet, or when the service suddenly stops working for some reason. I bet users would expect that when they save a scene to their hard drive, it stays on the hard drive, forever. |
@dwelle thanks for the feedback! I believe the extra file size can be addressed, see below. Just to set the context: I'm mainly shooting for a "wow" and "just works" experience for people and replace 2 buttons with just one. The way I see the UX for it is something like this: (I suggest we pre-select the checkbox) Regarding the size, here's the 1666 bytes JSON for the image above:
Looking at the structure of it, it's easy to imagine how we could use Thrift or something like it to encode the data in a much more space-efficient way. Additionally, PNG supports All in all, I'm sure we can make the source a tiny fraction of the resulting image. |
The idea of storing metadata in the image is really cool. My main concern is this meta data can be lost if the image is modified in any way. A lot of editors/transformation-code/CMSes may strip out this metadata when the image is reprocessed. |
@frantic right, that's better, but I'm not sure that storing metadata on PNG constitutes a "just works" UX. No one is gonna understand what's going on, because when you export a PNG, no other app then allows to reimport it to get to the original scene data --- that's not what people expect. So being the first (?), we'd need to make the explanation longer --- it's a big inferential leap. There's also the question of where one is going to look for scene export. I would never look at PNG export to do that, and having a checkbox saying "make editable in the future" won't help much. What happens when we support importing images into the scene? What takes precedence, the PNG bitmap, or the scene metadata? (Although this could be solved by having a prompt asking what the user wants to do in this case.) Either way, it still doesn't address the issue of wanting to store the scene-only. Why force people to store PNGs just when they want to keep the scene data around. What happens when we implement #253 or artboards with multiple slides/scenes? What do you export then, if we drop the support for exporting scene-only JSON files? |
All good points, thanks for taking time to elaborate! But consider the alternative—how many people are going to download the JSON along side the PNG to be able to edit the image in the future? I'd expect not many. Being able to edit the PNG to fix a typo would be a huge win. As for scenes and more complicated projects, I think that's separate and it ties into other discussions about server persistence and accounts support. This is more about embedding the source for the subset of shapes being exported. |
All the above said, I still think this idea is cool. IMO if it's implemented as such:
Then I'm personally all on board with this. Also note that I'm just voicing my concerns. (Also, I was arguing on users' behalf, not my own. My personal use case is: export PNGs to upload to imgur which has its own optimizer where I reckon the metadata is stripped. And not having to keep separate JSON files is actually cool with me.) |
Soon we could store these JSON files in the backend.. #409 |
@frantic Didn't notice your last comment before posting my own.
Still doesn't address the case where I'm not connected to the internet, or I elect not to log-in or don't want to persist potentially private data on more-or-less public server. Also, the idea of Excalidraw was to be simple and fast, without forcing users to log-in. Adding a feature to bundle scene data into PNG shouldn't come at a cost of forcing users to have to sign-in to persist their (more-complex) scenes. |
no need to sign in... only if they choose to share via URL.. otherwise you can always download the JSON, why bloating with PNG something that only Excalidraw could resolve.. |
@lipis oh, I thought you were arguing to do away with the JSON export in favor of persisting on backend. Anyway, I've stated my concerns, so I'll back off this issue for now, let others speak :). |
Let's not embed stuff in PNG files.. |
Hi, I think this is a killer feature at least for me. You can do this for example with draw.io. How they do that ? Simplify store the source as a base64 blob in the PNG metadata. I personally use this all the time because I keep loosing the source. :( Why I think it is useful ? Because you don't have to keep two files. You can just import the PNG and you can start editing again ! It could be an option like draw.io for people who don't want it (space issue or other concerns) like @frantic has shown. |
Ok, I'm reopening this for discussion. |
I believe this would be a great idea (maybe additionally/alternatively with an option to embed it in SVGs, which would probably be even easier). A quick overview of why I think this would be a great feature (especially in SVGs):I, in a few smaller software development teams (many projects are also open-source), am often responsible for keeping the project documentation up-to-date (I'm one of the few weird people who like writing documentation 😜). Especially for internal documentation (and, depending on the formality of a project, also public documentation), I love to use Excalidraw because of its speed and not having to focus on getting everything pixel-perfect. Storing both sources and results (image files) for diagrams in a repository with multiple people working on it can be quite a challenge (especially as in small teams, there often isn't a lot of time for writing documentation). Manually checking that everything's "in-sync" takes time, the instructions on how to edit a specific file are often not read by people who "just want to fix a quick mistake", it can be a challenge to get everyone to export the image to the right location again and so on. Let's take the SVG "variant". If this embeds the source as a simple comment at the top including an "Only edit this file using Excalidraw" notice (cf. my proposal below), having that SVG file still be editable in Excalidraw would help in a lot of ways:
Proposal for embedding the structure into an SVG export:(I don't mean it should be done exactly this way, this is just meant as a quick idea on how this could be achieved) <!-- Do not edit this file with editors other than Excalidraw -->
<!-- excalidraw-document: {...} -->
<svg>...</svg> |
Great idea. My use-case would be storing PNG (with metadata) into Git repository of a project, so that I or anyone else could modify it later on (+ it can be displayed in any markdown file as it's just PNG). |
As someone else pointed out, draw.io supports this with png files. Create a diagram and export to .png. You can open the png with the drawing tool later and edit it. The save operation saves as png at that point, no export needed that time. It makes it easy to put editable diagrams in source repositories. |
Alright alright already 😅, here's a draft PR for the PNG: #2219 Try at https://excalidraw-git-embedscenetoimage.excalidraw.vercel.app/ |
I was thinking it would be cool if there was a way to export images with an ability to come back and edit them afterwards.
Excalidraw currently has two buttons to save data: one exports JSON, the other one exports PNG

Why have two buttons while we can get away with just one?
PNG allows text metadata or we could use stenography and embed the JSON into the exported pixels (e.g. as shades of white in the background or border).
The text was updated successfully, but these errors were encountered: