How to show image using data url in html page from ASP.NET MVC4 c# application ?
I tried code below in Chrome and in Internet Explorer but empty image appears. There are no errors in borwser console window.
Image url is returned form signature pad https://github.com/szimek/signature_pad
Is is possible to show it or should I convert to png file in controller ?
html:
<!DOCTYPE html>
<html>
<body>
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAxcAAADVCAYAAAAl6A0eAAAcKElEQVR4Xu3da6x0V1kHcG6ltlRQlKKI8WAwxEgU0GirEY7GGCVGazQRhKRvo0aIRvATaFSKEuWD0fpBjJfEt15CPxitH0CDUY RD6IR8QKCQTlyaSViEKFoAanPX/eKq7sz58x5z5rzzuW3k5XZM7P3s9b 7TUz65m998zDH2YiQIAAAQIECBAgQIDAAIGHD4ghBAECBAgQIECAAAECBB4mudAJCBAgQIAAAQIECBAYIiC5GMIoCAECBAgQIECAAAECkgt9gAABAgQIECBAgACBIQKSiyGMghAgQIAAAQIECBAgILnQBwgQIECAAAECBAgQGCIguRjCKAgBAgQIECBAgAABApILfYAAAQIECBAgQIAAgSECkoshjIIQIECAAAECBAgQICC50AcIECBAgAABAgQIEBgiILkYwigIAQIECBAgQIAAAQKSC32AAAECBAgQIECAAIEhApKLIYyCECBAgAABAgQIECAgudAHCBAgQIAAAQIECBAYIiC5GMIoCAECBAgQIECAAAECkgt9gAABAgQIECBAgACBIQKSiyGMghAgQIAAAQIECBAgILnQBwgQIECAAAECBAgQGCIguRjCKAgBAgQIECBAgAABApILfYAAAQIECBAgQIAAgSECkoshjIIQIECAAAECBAgQICC50AcIECBAgAABAgQIEBgiILkYwigIAQIECBAgQIAAAQKSC32AAAECBAgQIECAAIEhApKLIYyCECBAgAABAgQIECAgudAHCBAgQIAAAQIECBAYIiC5GMIoCAECBAgQIECAAAECkgt9gAABAgQIECBAgACBIQKSiyGMghAgQIAAAQIECBAgILnQBwgQIECAAAECBAgQGCIguRjCKAgBAgQIECBAgAABApILfYAAAQIECBAgQIAAgSECkoshjIIQIECAAAECBAgQICC50AcIECBAgAABAgQIEBgiILkYwigIAQIECBAgQIAAAQKSC32AAAECBAgQIECAAIEhApKLIYyCECBAgAABAgQIECAgudAHCBAgQIAAAQIECBAYIiC5GMIoCAECBAgQIECAAAECkgt9gAABAgQIECBAgACBIQKSiyGMghAgQIAAAQIECBAgILnQBwgQIECAAAECBAgQGCIguRjCKAgBAgQIECBAgAABApILfYAAAQIECBAgQIAAgSECkoshjIIQIECAAAECBAgQICC50AcIECBAgAABAgQIEBgiILkYwigIAQIECBAgQIAAAQKSC32AAAECBAgQIECAAIEhApKLIYyCECBAgAABAgQIECAgudAHCBAgQIAAAQIECBAYIiC5GMIoCAECBAgQIECAAAECkgt9gAABAgQIECBAgACBIQKSiyGMghAgQIAAAQIECBAgILnQBwgQIECAAAECBAgQGCIguRjCKAgBAgQIECBAgAABApILfYAAAQIECBAgQIAAgSECkoshjIIQIECAAAECBAgQICC50AcIECBAgAABAgQIEBgiILkYwigIAQIECBAgQIAAAQKSC32AAAECBAgQIECAAIEhApKLIYyCECBAgAABAgQIECAgudAHCBAgQIAAAQIECBAYIiC5GMIoCAECBAgQIECAAAECkgt9gAABAgQIECBAgACBIQKSiyGMghAgQIAAAQIECBAgILnQBwgQIECAAAECBAgQGCIguRjCKAgBAgQIECBAgAABApILfYAAAQIECBAgQIAAgSECkoshjIIQIECAAAECBAgQICC50AcIECBAgAABAgQIEBgiILkYwigIAQIECBAgQIAAAQKSC32AAAECBAgQIECAAIEhApKLIYyCECBAgAABAgQIECAgudAHCBAgQIAAAQIECBAYIiC5GMIoCAECBAgQIECAAAECkgt9gAABAgQIECBAgACBIQKSiyGMghAgQIAAAQIECBAgILnQBwgQIECAAAECBAgQGCIguRjCKAgBAgQIECBAgAABApILfYAAAQIECBAgQIAAgSECkoshjIIQIECAAAECBAgQICC50AcIECBAgAABAgQIEBgiILkYwigIAQIECBAgQIAAAQKSC32AAAECBAgQIECAAIEhApKLIYyCECBAgAABAgQIECAgudAHCBAgQIAAAQIECBAYIiC5GMIoCAECBAgQIECAAAECkgt9gAABAgQIECBAgACBIQKSiyGMghAgQIAAAQIECBAgILnQBwgQIECAAAECBAgQGCIguRjCKAgBAgQIECBAgAABApILfYAAAQIECBAgQIAAgSECkoshjIIQIECAAAECBAgQICC50AcIECBAgAABAgQIEBgiILkYwigIAQIECBAgQIAAAQKSC32AAAECBAgQIECAAIEhApKLIYyCECBAgAABAgQIECAgudAHCBAgQIAAAQIECBAYIiC5GMIoCAECBAgQIECAAAECkgt9gAABAgQIECBAgACBIQKSiyGMghAgQIAAAQIECBAgILnQBwgQIECAAAECBAgQGCIguRjCKAgBAgQIECBAgAABApILfYAAAQIECBAgQIAAgSECkoshjIIQIECAAAECBAgQICC50AcIECBAgAABAgQIEBgiILkYwigIAQIECBAgQIAAAQKSC32AAAECBAgQIECAAIEhApKLIYyCECBAgAABAgQIECAgudAHCBAgQIAAAQIECBAYIiC5GMIoCAECBAgQIECAAAECkgt9gAABAgQIECBAgACBIQKSiyGMghAgQIAAAQIECBAgILnQBwgQIECAAAECBAgQGCIguRjCKAgBAgQIECBAgAABApILfYAAAQIECBAgQIAAgSECkoshjIIQIECAAAECBAgQICC50AcIECBAgAABAgQIEBgiILkYwigIAQIECBAgQIAAAQKSC32AAAECBAgQIECAAIEhApKLIYyCECBAgAABAgQIECAgudAHCBAgQIAAAQIECBAYIiC5GMIoCAECBAgQIECAAAECkgt9gAABAgQIECBAgACBIQKSiyGMghAgQIAAAQIECBAgILnQBwgQIECAAAECBAgQGCIguRjCKAgBAgQIECBAgAABApILfYAAAQIECBAgQIAAgSECkoshjIIQIECAAAECBAgQICC50AcIECBAgAABAgQIEBgiILkYwigIAQIECBAgQIAAAQKSC32AAAECBAgQIECAAIEhApKLIYyCECBAgAABAgQIECAgudAHCBAgQIAAAQIECBAYIiC5GMIoCAECBAgQIECAAAECkgt9gAABAgQIECBAgACBIQKSiyGMghAgQIAAAQIECBAgILnQBwgQIECAAAECBAgQGCIguRjCKAgBAgQIECBAgAABApILfYAAAQIECBAgQIAAgSECkoshjIIQIECAAAECBAgQICC50AcIECBAgAABAgQIEBgiILkYwigIAQIECBAgQIAAAQKSC32AAAECBAgQIECAAIEhApKLIYyCECBAgAABAgQIECAgudAHCBAgQIAAAQIECBAYIiC5GMIoCAECBAgQIECAAAECkgt9gAABAgQIECBAgACBIQKSiyGMghAgQIAAAQIECBAgILnQBwgQIECAAAECBAgQGCIguRjCKAgBAgQIECBAgAABApILfYAAAQIECBAgQIAAgSECkoshjIIQIECAAAECBAgQICC50AcIECBAgAABAgQIEBgiILkYwigIAQIECBAgQIAAAQKSC32AAAECBAgQIECAAIEhApKLIYyCECBAgAABAgQIECAgudAHCBAgQIAAAQIEFgk8ox58XJWMF/ 9ylswEThNQHJxmpDnCRDYRYFPq41KyZQPzHY/85kOp8cz35bLB2y739bpbdq6LWZ77kNTrDzf13XcrZw6cn/err7 tvi83Q/0jaj5NgjIcn2b m2dt3FZ/a2uvu5F296eb/Utq7uPs2h7T6pvvp39ZrfPsvk aJ6nWfexWttzu6jOeV1t b7ufvv7bernT9qe1p75Z3S242DqJxnkte1r y/PzePO2zfvP/P sqyOvv/P 2K//9Pf0454LFpn1l0X3m2vlbSttf8ssbL dVWu7V4D87413 ftNfHEmrm/e3K //r 3 Y/WstfP9W1bH/3Rln241X tduHJ7m0vtXXk Xb/u/Xbe7X1IOfOCFo1n10lY91cVrb76vHHnPCuu u5/6gyquqHK yQy2zXwKSi/3a37aWwC4JHNTGpGQw9YzpAzLb1x7vP3w/fdrw/oMwH6R3V8kgLeskRu5nOpweX TVDz5P8pwP/Fp70obUl9vUnXpTLk/BLnV1t VyOx8cZRCRxxdNid3qy20brPWD0L7 xGnb3urPY619LVYb5Cwb1LTBVluub2Nipc7E7a1vmR7vl23b2lu3mG175h5zh/k2L7JO3YnT kCLsci6b1O2Y9Eyrc5s39G0TOaXxZ23edn9FjfPp 7EbG3u23GaySKjft82476OxMw WxZ7/ngGrE9a0r7U1ZKE1pYkI3kst5nm zl1Z1tTTyt9jH eHu9jJM4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Zk65b/oLi25EXBK0aAgQIECBAgMBVEjioeu o8i0n1J8jGUdVbquyrtOlXlCxX1Nl/oeH Qln/89ylTrH6GolF6NFxSNAgAABAgQIbKZAkoycKpUjFfnPjUVTrsvIn0 OSDAOK853VPmyqSxT8WtRm9lfrqhVkosrYrMSAQIECBAgQGCrBfIP389esgUfq8dfX WsRzFyytMPV/nqKjetqJP/4bi04rIW2wIBycUW7CRNJECAAAECBAisQeCwYubC6m ssujPLfO/LfmltvyC2xurPL5Kfs723ir56edMX1vlydPtwYpt/M9a7s1VfrpK/ujPtEMCkosd2pk2hQABAgQIECBwBQI/Wuv8 BWst oq76sF31nlaEomNuX/NlZtv XOICC5OAOWRQkQIECAAAECOyiw7BecrmRTP1wrva3KXVWSRCShMO2RgORij3a2TSVAgAABAgQInCDwvHruxio/VeX6BcvldKacIvUZVR6o8rgqb6qSX396w5RIOM1pz7uY5GLPO4DNJ0CAAAECBAjMBA7q/ldVua7KPVVycbeJwEoCkouVmCxEgAABAgQIECBAgMBpApKL04Q8T4AAAQIECBAgQIDASgKSi5WYLESAAAECBAgQIECAwGkCkovThDxPgAABAgQIECBAgMBKApKLlZgsRIAAAQIECBAgQIDAaQKSi9OEPE AAAECBAgQIECAwEoCkouVmCxEgAABAgQIECBAgMBpAv8DFBfj9Ld6cr0AAAAASUVORK5CYII=" height="100" width="300">
</body></html>
Razor view:
<img src="@Model.ImageData()" height="100" width="300" />
Is is possible to show it... ?
Yes, it is perfectly possible to show base64 encoded images on <img>
's tag src
attribute.
http://jsfiddle.net/7dnygshL/
Just, be aware that on the base64 image your provided, the image is a pure transparent image... That may be confusing you, but inspect the element and see that the image is been loaded...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With