Base64 To Image Converter helps you convert Base64 code to image and you could preview the image and download.
I am trying to convert a Base64String to an image which needs to be saved locally.
At the moment, my code is able to save the image but when I open the saved image, it says 'Invalid Image'.
Code:
The
SubbySubbyContent
is a string
object which contains the Base64 String.1,75313 gold badges57 silver badges108 bronze badges
4 Answers
Paul FarryPaul Farry3,7341 gold badge24 silver badges52 bronze badges
First, convert the base 64 string to an
Image
, then use the Image.Save
method.To convert from base 64 string to
Image
:To convert from
Image
to base 64 string:Finally, you can easily to call
johnnyRoseImage.Save(filePath);
to save the image.4,33911 gold badges36 silver badges54 bronze badges
MonahMonah5,4705 gold badges18 silver badges48 bronze badges
MethodMan16k6 gold badges27 silver badges49 bronze badges
Hussain Ahmed ShamsiHussain Ahmed Shamsi
Rajesh-SystematixRajesh-Systematix
Not the answer you're looking for? Browse other questions tagged c#imagebase64jpegencode or ask your own question.
Purely out of curiosity, which browsers does Base64 image embedding work in? What I'm referring to is this.
I realize it's not usually a good solution for most things, as it increases the page size quite a bit - I'm just curious.
Some examples:
HTML:
![Base64 to image npm Base64 to image npm](http://is1.mzstatic.com/image/thumb/Purple82/v4/58/13/99/581399bb-3585-bd3b-4e05-0b2e95eb4f52/source/512x512bb.png)
CSS:
dda5,5042 gold badges20 silver badges32 bronze badges
S PangbornS Pangborn8,3636 gold badges20 silver badges24 bronze badges
3 Answers
Update: 2017-01-10
Data URIs are now supported by all major browsers. IE supports embedding images since version 8 as well.
Data URIs are now supported by the following web browsers:
- Gecko-based, such as Firefox, SeaMonkey, XeroBank, Camino, Fennec and K-Meleon
- Konqueror, via KDE's KIO slaves input/output system
- Opera (including devices such as the Nintendo DSi or Wii)
- WebKit-based, such as Safari (including on iOS), Android's browser, Epiphany and Midori (WebKit is a derivative of Konqueror's KHTML engine, but Mac OS X does not share the KIO architecture so the implementations are different), as well as Webkit/Chromium-based, such as Chrome
- Trident
- Internet Explorer 8: Microsoft has limited its support to certain 'non-navigable' content for security reasons, including concerns that JavaScript embedded in a data URI may not be interpretable by script filters such as those used by web-based email clients. Data URIs must be smaller than 32 KiB in Version 8[3].
- Data URIs are supported only for the following elements and/or attributes[4]:
- object (images only)
- img
- input type=image
- link
- CSS declarations that accept a URL, such as background-image, background, list-style-type, list-style and similar.
- Internet Explorer 9: Internet Explorer 9 does not have 32KiB limitation and allowed in broader elements.
- TheWorld Browser: An IE shell browser which has a built-in support for Data URI scheme
13.4k5 gold badges38 silver badges38 bronze badges
Most modern desktop browsers such as Chrome, Mozilla and Internet Explorer support images encoded as data URL. But there are problems displaying data URLs in some mobile browsers: Android Stock Browser and Dolphin Browser won't display embedded JPEGs.
I reccomend you to use the following tools for online base64 encoding/decoding:
Check the 'Format as Data URL' option to format as a Data URL.
CodeCaster112k18 gold badges160 silver badges207 bronze badges
Brig AderBrig Ader
Can I use (http://caniuse.com/#feat=datauri) shows support across the major browsers with few issues on IE.
keherskehers2,4843 gold badges22 silver badges30 bronze badges
protected by Mosty MostachoMay 26 '14 at 16:26
Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?
Would you like to answer one of these unanswered questions instead?