Last active
August 19, 2016 15:46
-
-
Save vadimkantorov/ea85b070f99235644baf to your computer and use it in GitHub Desktop.
A Matlab snippet to output Base64-encoded img's to be used for HTML visualizations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
f = figure(); | |
plot(1:10, 1:10); | |
rgbData = figToImStream('figHandle', f, 'imageFormat', 'jpg', 'outputType', 'uint8'); | |
%print(f, '-djpg', '/tmp/vis.jpg'); rgbData = fread(fopen('/tmp/vis.jpg'), 'uint8=>uint8'); % replace previous line by this line in case of failure | |
fprintf('<img src="data:image/jpeg;base64,%s" />', char(org.apache.commons.codec.binary.Base64.encodeBase64(rgbData))'); | |
close(f); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment