Image in XML
-
Is this possible? Like include binary data in XML that will magic transform into image? I think not, if you think yes, show me how it is done.
-
-
As if by magic? No. With a little bit of encoding and decoding? Yes, you can include any blob of bytes (encode it first or you will bloat the xml even more). The real question is why would you want to? If you need to do this then something has gone terribly terribly wrong.
-
@locallunatic said:
encode it first or you will bloat the xml even more
As one of the links I cited mentioned, uuencoding the data is an option. The method used to explode the size of emails with attachments with an overhead of 40%.
-
Yes! After a little conversion, of course.
-
@PJH said:
As one of the links I cited mentioned, uuencoding the data is an option. The method used to explode the size of emails with attachments with an overhead of 40%.
The uuencode and base64 encodings have such large overhead because they use multiple ASCII characters (i.e. multiple bytes) to represent the value of one byte. The yEnc encoding largely maps byte values directly to single characters and only requires a very small set of input values to be escaped with a leading '=' character. This gives it a much lower average overhead. (There are claims that it can be as low as 1% – 2% when the distribution of recurring byte sequences is optimal.)
You could safely embed yEnc encoded data in XML by escaping any illegal characters first; it adds a minor amount of additional overhead, but would still be more efficient than uuencode or base64.
-
<image width="64" height="64><pixel x="0" y="0" red="255" green="128" blue="255"/><pixel x="1" y="0" red="128" green="255" blue="64">*bang*
-
It's called SVG.