I have seen the base64 encoded URI earlier and knew what it is essentially. For example:
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAkIAAADICAYAAAAEE46XAAALwElEQVR4Xu3ZUW7dVgwE0GRD3f86uqEWBVLARlUIxBXEeZmTb8uPPEMbE/nnD/8IECBAgAABAqUCP0v3tjYBAgQIECBA4Ici5AgIECBAgACBWgFFqDZ6ixMgQIAAAQKKkBsgQIAAAQIEagUUodroLU6AAAECBAgoQm6AAAECBAgQqBVQhGqjtzgBAgQIECCgCLkBAgQIECBAoFZAEaqN3uIECBAgQICAIuQGCBAgQIAAgVoBRag2eosTIECAAAECipAbIECAAAECBGoFFKHa6C1OgAABAgQIKEJugAABAgQIEKgVUIRqo7c4AQIECBAgoAi5AQIECBAgQKBWQBGqjd7iBAgQIECAgCLkBggQIECAAIFaAUWoNnqLEyBAgAABAoqQGyBAgAABAgRqBRSh2ugtToAAAQIECChCboAAAQIECBCoFVCEaqO3OAECBAgQIKAIuQECBAgQIECgVkARqo3e4gQIECBAgIAi5AYIECBAgACBWgFFqDZ6ixMgQIAAAQKKkBsgQIAAAQIEagUUodroLU6AAAECBAgoQm6AAAECBAgQqBVQhGqjtzgBAgQIECCgCLkBAgQIECBAoFZAEaqN3uIECBAgQICAIuQGCBAgQIAAgVoBRag2eosTIECAAAECipAbIECAAAECBGoFFKHa6C1OgAABAgQIKEJugAABAgQIEKgVUIRqo7c4AQIECBAgoAi5AQIECBAgQKBWQBGqjd7iBAgQIECAgCLkBggQIECAAIFaAUWoNnqLEyBAgAABAoqQGyBAgAABAgRqBRSh2ugtToAAAQIECChCboAAAQIECBCoFVCEaqO3OAECBAgQIKAIuQECBAgQIECgVkARqo3e4gQIECBAgIAi5AYIECBAgACBWgFFqDZ6ixMgQIAAAQKKkBsgQIAAAQIEagUUodroLU6AAAECBAgoQm6AAAECBAgQqBVQhGqjtzgBAgQIECCgCLkBAgQIECBAoFZAEaqN3uIECBAgQICAIuQGCBAgQIAAgVoBRag2eosTIECAAAECipAb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kARqo3e4gQIECBAgIAi5AYIECBAgACBWgFFqDZ6ixMgQIAAAQKKkBsgQIAAAQIEagUUodroLU6AAAECBAgoQm6AAAECBAgQqBVQhGqjtzgBAgQIECCgCLkBAgQIECBAoFZAEaqN3uIECBAgQICAIuQGCBAgQIAAgVoBRag2eosTIECAAAECipAbIECAAAECBGoFFKHa6C1OgAABAgQIKEJugAABAgQIEKgVUIRqo7c4AQIECBAgoAi5AQIECBAgQKBWQBGqjd7iBAgQIECAgCLkBggQIECAAIFaAUWoNnqLEyBAgAABAoqQGyBAgAABAgRqBRSh2ugtToAAAQIECChCboAAAQIECBCoFVCEaqO3OAECBAgQIKAIuQECBAgQIECgVkARqo3e4gQIECBAgIAi5AYIECBAgACBWgFFqDZ6ixMgQIAAAQKKkBsgQIAAAQIEagUUodroLU6AAAECBAgoQm6AAAECBAgQqBVQhGqjtzgBAgQIECCgCLkBAgQIECBAoFZAEaqN3uIECBAgQICAIuQGCBAgQIAAgVoBRag2eosTIECAAAECipAbIECAAAECBGoFFKHa6C1OgAABAgQIKEJugAABAgQIEKgVUIRqo7c4AQIECBAgoAi5AQIECBAgQKBWQBGqjd7iBAgQIECAgCLkBggQIECAAIFaAUWoNnqLEyBAgAABAoqQGyBAgAABAgRqBRSh2ugtToAAAQIECChCboAAAQIECBCoFVCEaqO3OAECBAgQIKAIuQECBAgQIECgVkARqo3e4gQIECBAgMDfiLaSyZOoJNUAAAAASUVORK5CYII
The browser does the job of displaying it seamlessly most of the time. However, today I got it as text in a email. The email client wrapped each line by = and newline character. So I got curious how to "view" the image.
I took the following steps (possibly unnecessary as base64 command can strip garbage from input*):
- Saved the encoded data to a text file
- Used sed with the following commands to strip unneeded characters (I'm nowhere a sed expert :( )
~$&> sed 's/=$//' imagedata.txt > imagedata.txt
(remove trailing = on each line)~$&> sed ':a;N;$!ba;s/\n//g' imagedata.txt > imagedata2.txt
(remove newline character from each line)~$&> base64 -d -w 0 imagedata2.txt > imagedata.png
*: see base64 man page
No comments:
Post a Comment