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

Embedding the input string to PNG, SVG and EPS #20

Open
fukuchi opened this issue Sep 22, 2012 · 1 comment
Open

Embedding the input string to PNG, SVG and EPS #20

fukuchi opened this issue Sep 22, 2012 · 1 comment

Comments

@fukuchi
Copy link
Owner

fukuchi commented Sep 22, 2012

David Dahl suggests:

Another item I have been thinking about is the possibility of
including the input string's value as metadata in the image file. It
may be advantageous to include this as a tEXt or iTXt chunk with a
"comment" key in a PNG, or a <desc>...</desc> or <title>...</title>
pair in an SVG.

While I like this suggestion, the implementation seems to be not simple:

  1. How to embed binary (8-bit) data?
  2. Embedding text data to SVG/EPS may require sanitizing.

Your comments are welcome.

@Oblomov
Copy link

Oblomov commented Feb 9, 2014

This is something I have been thinking about as well, although my initial plan was to add the original text as comment (in SVG as well). Using a title tag would definitely make more sense though.

For SVG, one could resort to plopping the thing in a CDATA: the only care that needs to be taken then is that the (unlikely) sequence ]]> must be split across two CDATA sections, which is very easy to do. The only thing that should be ensured is that the character encoding of the XML is set correctly (so, shift_jis or iso-8859-1 as appropriate).

For EPS, the text would need to go in some comment, so the only escaping that would be needed is that of newlines, probably, although I' d have to refresh my knowledge of EPS and the DSC to be sure about that.

For PNG with arbitrary data, one could encode the thing with base64 before stuffing it in a text chunk if it contains anything that is not a printable latin1 character.

I'll see if I can cook up something for the SVG part. EDIT: I've started working on the feature in my embed-intext branch.

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

2 participants