Decode Image from Base64Import numeric values from XMLSlow import of multigigabyte TIF image stacksLook up...
Why exactly is the answer 50 ohms?
How to respond to "Why didn't you do a postdoc after your PhD?"
What power does the UK parliament hold over a Prime Minister whom they refuse to remove from power?
Any Issues with running Workbench 1.3 on a Kickstart 1.2 Amiga 500?
What does this text mean with capitalized letters?
Is there a historical explanation as to why the USA people are so litigious compared to France?
Incorrect mmap behavior when assembly files included in the project
3-prong to 4-prong conversion - EXTRA MISLABELLED WIRES - Dryer cable upgrade and installation
Text on old-fashioned differential geometry
Who is Sifter, and what is "the so-called Sifter flare"?
The travel to a friend
Advisor asked for my entire slide presentation so she could give the presentation at an international conference
Neither Raman nor IR Active vibrational modes
I am often given, occasionally stolen, rarely sold, and never borrowed
Usefulness of Nash embedding theorem
A curious 5x5 square
Easy way of generating a 50-150W load @12V
What could possibly power an Alcubierre drive?
Why is the empennage design of this Lockheed 1049E so complicated?
Is it possible to have 2 ports open on SSH with 2 different authentication schemes?
What does the British parliament hope to achieve by requesting a third Brexit extension?
Standard cumulative distribution function with optimization model variable
XDSL Internet Connection Over Optical Fibre Telephone Line?
How can a "proper" function have a vertical slope?
Decode Image from Base64
Import numeric values from XMLSlow import of multigigabyte TIF image stacksLook up info associated with a given CAS chemical identifier from the NIST webbook & NCI CADD Chemical Identifier ResolverImporting a Base64 encoded stringHow to correctly import data zipped with the “deflate” algorithm?Decode a text which is encoded with UTF-8Why Base64 ends with a newline? (n)Problem with importing .tiff imageImporting a raw image
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{
margin-bottom:0;
}
.everyonelovesstackoverflow{position:absolute;height:1px;width:1px;opacity:0;top:0;left:0;pointer-events:none;}
$begingroup$
From a web API, I have a bunch of realllyyy long strings that look like this:
data:image/jpeg;base64,(...)
Sites like this will decode these strings no problem, but Mathematica doesn't seem to be able to. BaseDecode
gives me a ByteArray which can't be re-imported as a JPEG, and ImportString doesn't want to import as a JPEG either.
Is there any way, in Mathematica, to convert from a base64 encoded image to the image itself?
For experimentation, here is a dump of one of the image strings. It should end up looking like a semi-messed up cathedral thingy (I'm training GANs)
import string-manipulation image
$endgroup$
add a comment
|
$begingroup$
From a web API, I have a bunch of realllyyy long strings that look like this:
data:image/jpeg;base64,(...)
Sites like this will decode these strings no problem, but Mathematica doesn't seem to be able to. BaseDecode
gives me a ByteArray which can't be re-imported as a JPEG, and ImportString doesn't want to import as a JPEG either.
Is there any way, in Mathematica, to convert from a base64 encoded image to the image itself?
For experimentation, here is a dump of one of the image strings. It should end up looking like a semi-messed up cathedral thingy (I'm training GANs)
import string-manipulation image
$endgroup$
add a comment
|
$begingroup$
From a web API, I have a bunch of realllyyy long strings that look like this:
data:image/jpeg;base64,(...)
Sites like this will decode these strings no problem, but Mathematica doesn't seem to be able to. BaseDecode
gives me a ByteArray which can't be re-imported as a JPEG, and ImportString doesn't want to import as a JPEG either.
Is there any way, in Mathematica, to convert from a base64 encoded image to the image itself?
For experimentation, here is a dump of one of the image strings. It should end up looking like a semi-messed up cathedral thingy (I'm training GANs)
import string-manipulation image
$endgroup$
From a web API, I have a bunch of realllyyy long strings that look like this:
data:image/jpeg;base64,(...)
Sites like this will decode these strings no problem, but Mathematica doesn't seem to be able to. BaseDecode
gives me a ByteArray which can't be re-imported as a JPEG, and ImportString doesn't want to import as a JPEG either.
Is there any way, in Mathematica, to convert from a base64 encoded image to the image itself?
For experimentation, here is a dump of one of the image strings. It should end up looking like a semi-messed up cathedral thingy (I'm training GANs)
import string-manipulation image
import string-manipulation image
asked 9 hours ago
TreFoxTreFox
1,6208 silver badges23 bronze badges
1,6208 silver badges23 bronze badges
add a comment
|
add a comment
|
1 Answer
1
active
oldest
votes
$begingroup$
You just got to remove the initial data:image/jpeg;base64,
, everything after that is base64 encoded pixel data.
data = Import["https://pastebin.com/raw/KHE6A3gR", "Text"];
data = StringReplace[data, "data:image/jpeg;base64," -> ""];
ImportString[data, "Base64"]
$endgroup$
$begingroup$
Oh nice! I assumed it would need that to infer the type. Thank you!
$endgroup$
– TreFox
9 hours ago
add a comment
|
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "387"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f207466%2fdecode-image-from-base64%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
You just got to remove the initial data:image/jpeg;base64,
, everything after that is base64 encoded pixel data.
data = Import["https://pastebin.com/raw/KHE6A3gR", "Text"];
data = StringReplace[data, "data:image/jpeg;base64," -> ""];
ImportString[data, "Base64"]
$endgroup$
$begingroup$
Oh nice! I assumed it would need that to infer the type. Thank you!
$endgroup$
– TreFox
9 hours ago
add a comment
|
$begingroup$
You just got to remove the initial data:image/jpeg;base64,
, everything after that is base64 encoded pixel data.
data = Import["https://pastebin.com/raw/KHE6A3gR", "Text"];
data = StringReplace[data, "data:image/jpeg;base64," -> ""];
ImportString[data, "Base64"]
$endgroup$
$begingroup$
Oh nice! I assumed it would need that to infer the type. Thank you!
$endgroup$
– TreFox
9 hours ago
add a comment
|
$begingroup$
You just got to remove the initial data:image/jpeg;base64,
, everything after that is base64 encoded pixel data.
data = Import["https://pastebin.com/raw/KHE6A3gR", "Text"];
data = StringReplace[data, "data:image/jpeg;base64," -> ""];
ImportString[data, "Base64"]
$endgroup$
You just got to remove the initial data:image/jpeg;base64,
, everything after that is base64 encoded pixel data.
data = Import["https://pastebin.com/raw/KHE6A3gR", "Text"];
data = StringReplace[data, "data:image/jpeg;base64," -> ""];
ImportString[data, "Base64"]
answered 9 hours ago
C. E.C. E.
55.9k3 gold badges109 silver badges222 bronze badges
55.9k3 gold badges109 silver badges222 bronze badges
$begingroup$
Oh nice! I assumed it would need that to infer the type. Thank you!
$endgroup$
– TreFox
9 hours ago
add a comment
|
$begingroup$
Oh nice! I assumed it would need that to infer the type. Thank you!
$endgroup$
– TreFox
9 hours ago
$begingroup$
Oh nice! I assumed it would need that to infer the type. Thank you!
$endgroup$
– TreFox
9 hours ago
$begingroup$
Oh nice! I assumed it would need that to infer the type. Thank you!
$endgroup$
– TreFox
9 hours ago
add a comment
|
Thanks for contributing an answer to Mathematica Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f207466%2fdecode-image-from-base64%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown