[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Base64 String to Image Matrix

From: alex jones
Subject: Base64 String to Image Matrix
Date: Mon, 5 Sep 2016 13:15:36 -0700 (PDT)

I have buit a front end web app that outputs 28x28 pixel RGB images (.png) in
this base64 format (below is an image of the number 9 - can view image here: 


I would like to convert this to a 28x28x3 image matrix in Octave just as the
imread function does. Here is what works given the above string stored in
variable imageBase64.

raw = base64decode(imageBase64);
fid = fopen('buffer.png', 'wb');
fwrite(fid, raw, 'uint8');
I = imread('buffer.png');

Though this outputs an I matrix of 28x28x3 dimension, for the application
that I am building I cannot be saving to file and reading the file
afterwards. I know the imread function only takes a file path as an input.
Is there any way to go directly from the base64 string to the I matrix
without writing/reading to file in Octave.

Would really appreciate your help.

View this message in context:
Sent from the Octave - General mailing list archive at

reply via email to

[Prev in Thread] Current Thread [Next in Thread]