Convert Image Stream (JFIF - JPEG) format to DataURI using Javascript
I have tried to search an answer for this all over. It seems pretty
straightforward, but my lack of knowledge of Javascript (Been coding in
Java all along) combined with Image stream conversion on Javascript side
makes this hard.
I make a REST request url - https://<:port/getPicture and it produces a
image/jpeg streaming response.
Once I fire the url in Chrome browser - the image is rendered correctly.
It is also rendered in my angularJS app - via ng-src tag e.g.
However, when I try to set the raw data to ng-src tag, it does not seem to
work. On further reading I understood that ng-src does not accept raw
image data, but needs to be converted to a base64String to be used as a
DataURI. I tried to look up articles everywhere to convert raw image data
(JFIF format) to DataURI and was unsuccessful.
Shown below is response raw data looks (I open it in a browser, it renders
perfectly).
Questions - 1. What format is the raw data? Binary Stream or Byte Array?
Or what is it? 2. How do I convert this in to a DataURI in Javascript so
that it can be linked to my ng-src tag?
Request you to help me on this one. Seems so easy, but has taken me a week
now and driving me nuts!!
����JFIF``��C $.'
,#(7),01444'9=82lt;.342��C /p
p2!!22222222222222222222222222222222222222222222222222���|��
���}!1AQaq2���#B��R��$3br�br
%amp;'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz���������������������������������������������������������������������������br
���w!1AQaq2�B����
#3R�br�
$4�%�amp;'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz��������������������������������������������������������������������������?�4���)����4�㊎D,W�}jLsIބ�Y~{鑻a��6�ҙb�'��I�Fj�+��K�R
�dhr=���4�������+R~S���Zq��g
�5Vղ_��[�y��(,�����Ґ2�$?Z@(��K��I�|Ro��G#қ��K�Ґ��pM7|7w��I���Q@��)��J��jIeo��?�篵Z�����9��8�a����[W%�r��F2E4Es�e��/������]��i�92�Pf���݃yo��O��n���9f�]�;W�=zRt��綃ނ*}Z{ׂ�P!�̤�YEt�s�!���s���zR�EQdP�]\��b�@̫����Q�
;�����d��k��t�amp;�Nk�L��@f�amp;��u�����������code���-�s�/
���ʪF�p)�f�c�(aLd?p�I�I��7Rr=h��i����2=�2�4���P��'�3擨*����%ߖ�*]��/codeQ�ڌ�amp;G�+��5䈹E��Mu2F����E���jϔp�����_�qp����^�V������^�ː���̬b�'l�E/��'漛��/p
No comments:
Post a Comment