This is a simple example of how one might store an image on a DNS server using TXT records. This may be useful for redundancy or to insure that an image remains available for an extended period of time without requiring a webserver to provide the image data. For example, a domain's registration may be pre-paid to last for the next 10 years, which would insure that the data is available online for the next 10 years regardless of whether the domain is currently hosting a website.
The maximum length of data stored in this manner using base64 encoding is 3,000 bytes.
To display an image stored in a DNS TXT record, a server-side application must use a DNS lookup tool such as dig to retrieve the TXT record, and then concatenate the records in the reverse order in which they are returned from the DNS server and return the concatenated data to the user's browser, which may be loaded as base64 encoded data inside of an IMG tag pointing to the retrieval service. Multiple TXT records are stored left-to-right on a single line in BIND as they are added to a DNS server, and so the ordering is preserved for re-assembly.
For my example I have stored this image:
An example of retrieving this data follows, using the Linux dig command to retrieve the record:
amrita@localhost:~$ dig nft.bithi.me TXT
; <<>> DiG 9.16.1-Ubuntu <<>> nft.bithi.me TXT
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 48344
;; flags: qr rd ra; QUERY: 1, ANSWER: 15, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 65494
;; QUESTION SECTION:
;nft.bithi.me. IN TXT
;; ANSWER SECTION:
nft.bithi.me. 300 IN TXT "uJzgzA/r1voHcb0SnEZXfxCoPpP3mCMKTWKXwjY5YKPxnvOCMtz9ZKmeIynjNBs2uXrpuI3PFxHNu3Gi7PS6Z4wxubRbr2Pl/+185I8o9Td9/G1X3frHMJ3VaX77+MN58I6wxiYpO/QC+bSxb4dNouzC8wdfFWuSx3VMcaQQw2deOlfsaGP+4heK0rMnfp8QZWzurd7iJ4RmcpOfiOBCsxbfuVanIPX/lvh/EMMbIlJ8ElJzYl5QU4XMeNwZaur"
nft.bithi.me. 300 IN TXT "9TIkjTNMKjNrqeSUy/QuUCcWJqzAdLHHgNQS7JPIOQSajQWQAhao9M+2JBFCr3wPNqnUN42MaBMrd+iWoP9sUCTS7Eqt2uggoFeArxgZytALLWX2Q41Faob6B/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AGQAAABkCAAAAABVicqIAAAKkUlEQVRo3tWaeVwTVx7AZwKCSl2lpd6lqOyKVld3W91at65+rFt1/dS2Xuu6q1tqadXaelWFT73a6qp4dD9aASuHCireKyptRdBV0MopKiIiSLiSTMKREEhCJu7vzUwyM8mbJJDs57P7/klm3pv3nffmd88QzyyoGTVMMzIHlgbmQMce6JiDBkvnx"
nft.bithi.me. 300 IN TXT "T0pcfxyjyEv4YDBW1nyC/xx7q85rn/mUZR3dMPmXfKQt6zl4wtrEn0qU3v5gyaB+VJR5LP5gXHxKRmGpqs3bHyz9X3zfJf05XIubEJfjnv0HieqmfRQ8f+0AAAAASUVORK5CYII="
;; Query time: 508 msec
;; SERVER: 127.0.0.53#53(127.0.0.53)
;; WHEN: Sun Feb 20 05:56:41 PST 2022
;; MSG SIZE rcvd: 3942