Closed lpatiny closed 8 months ago
Do you have an example of file with such textual information so we can understand:
I guess one idea is that when you copy a molecule as PNG we can insert the smiles or molfile in it so that if we somehow copy it back from another software we cane extract the chemical structure.
Using imagemagick
we can add a new keyword in a PNG using:
convert butane.png -set 'Smiles' 'CCCC' butane_meta.png
We can check if the keyword has been added using identify --verbose butane_meta.png
You will find here both images before and after adding the Smiles
There are 3 possible chunks:
FWIW excalidraw exports a png with a json in the metadata so that it can be re-edited:
This is the png with the embedded data:
Both your examples use the tEXt
chunk, so we only need to implement the encoder part of it.
BTW, thanks @stropitek for your example, it made me realize that the decoding was wrong. Fixed in https://github.com/image-js/fast-png/pull/39
@lpatiny is latin1
enough for your use case?
Yes latin1 is enough for SMILES and molfile.
When encoding an image we would need to be able to add textual information following the specifications:
https://www.w3.org/TR/PNG/#11textinfo
We should also ensure that decoding can read those information.