Closed aberba closed 4 years ago
It can be done with std.base64 and ArrayStream:
import std.base64;
import dlib;
void main()
{
string base64 = "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADklEQVR42mL4z8AAEGAAAwEBAGb9nyQAAAAASUVORK5CYII=";
ubyte[] buffer = Base64.decode(base64);
auto strm = new ArrayStream(buffer, buffer.length);
SuperImage img = loadPNG(strm);
img.savePNG("out.png");
}
Nice. Thanks.
Is there a way in dlib to convert a base64 image string (or decoded buffer) to a png or jpg format? I'm able to decode it to a buffer but turning a buffer into and Image is not something trivial without knowledge in image processing, I think.