Shorten image data which is transformed into base64 - html

I have this image which I transformed into base64. The issue is the string that it gave me is so huge, I'm not able to see any other lines of codes. I inputted the given string in the source tag and it works the image. How do I shorten the base64 data of the image in order to see other lines of code?.
[an example of the string (couldn't fit the whole screenshot as it's so big)]
Was expecting the base64 string to be short in order to put it in the tag.

Related

Browser adding double quotes in URI query string

My searches have been fruitless. I am coding a page that will have an anchor link to send query results to a second page to produced a tabulated csv file download.
The main page runs the query. I serialized the results as JSON and encoded them:
%5B%7B%22SELECT%5FREASON%22%3A%2201%22%2C%22IMPOSED%5FACTION%22%3Anull%2C%22DISP%5FTYPE%5FTEXT%22%3Anull%2C%22COUNT%22%3A496%2C%22DATE%22%3A20220712%7D%2C%7B%22SELECT%5FREASON%22%3A%2202%22%2C%22IMPOSED%5FACTION%22%3Anull%2C%22DISP%5FTYPE%5FTEXT%22%3Anull%2C%22COUNT%22%3A412%2C%22DATE%22%3A20220712%7D%2C%7B%22SELECT%5FREASON%22%3A%2205%22%2C%22IMPOSED%5FACTION%22%3Anull%2C%22DISP%5FTYPE%5FTEXT%22%3Anull%2C%22COUNT%22%3A332%2C%22DATE%22%3A20220712%7D%2C%7B%22SELECT%5FREASON%22%3A%2206%22%2C%22IMPOSED%5FACTION%22%3Anull%2C%22DISP%5FTYPE%5FTEXT%22%3Anull%2C%22COUNT%22%3A60%2C%22DATE%22%3A20220712%7D%2C%7B%22SELECT%5FREASON%22%3A%2207%22%2C%22IMPOSED%5FACTION%22%3Anull%2C%22DISP%5FTYPE%5FTEXT%22%3Anull%2C%22COUNT%22%3A258%2C%22DATE%22%3A20220712%7D%2C%7B%22SELECT%5FREASON%22%3A%2209%22%2C%22IMPOSED%5FACTION%22%3Anull%2C%22DISP%5FTYPE%5FTEXT%22%3Anull%2C%22COUNT%22%3A300%2C%22DATE%22%3A20220712%7D%2C%7B%22SELECT%5FREASON%22%3A%2212%22%2C%22IMPOSED%5FACTION%22%3Anull%2C%22DISP%5FTYPE%5FTEXT%22%3Anull%2C%22COUNT%22%3A242%2C%22DATE%22%3A20220712%7D%2C%7B%22SELECT%5FREASON%22%3A%2213%22%2C%22IMPOSED%5FACTION%22%3Anull%2C%22DISP%5FTYPE%5FTEXT%22%3Anull%2C%22COUNT%22%3A282%2C%22DATE%22%3A20220712%7D%2C%7B%22SELECT%5FREASON%22%3A%2214%22%2C%22IMPOSED%5FACTION%22%3Anull%2C%22DISP%5FTYPE%5FTEXT%22%3Anull%2C%22COUNT%22%3A2%2C%22DATE%22%3A20220712%7D%2C%7B%22SELECT%5FREASON%22%3A%2215%22%2C%22IMPOSED%5FACTION%22%3Anull%2C%22DISP%5FTYPE%5FTEXT%22%3Anull%2C%22COUNT%22%3A180%2C%22DATE%22%3A20220712%7D%2C%7B%22SELECT%5FREASON%22%3A%2216%22%2C%22IMPOSED%5FACTION%22%3Anull%2C%22DISP%5FTYPE%5FTEXT%22%3Anull%2C%22COUNT%22%3A30%2C%22DATE%22%3A20220712%7D%2C%7B%22SELECT%5FREASON%22%3A%2217%22%2C%22IMPOSED%5FACTION%22%3Anull%2C%22DISP%5FTYPE%5FTEXT%22%3Anull%2C%22COUNT%22%3A6%2C%22DATE%22%3A20220712%7D%5D
The source on the page reflects this, but when I hover over the link (or go ahead and send it) all of the unencoded (plain text) portions are now quoted.
%27%5B%7B"SELECT_REASON"%3A"01"%2C"IMPOSED_ACTION"%3Anull%2C"DISP_TYPE_TEXT"%3Anull%2C"COUNT"%3A496%2C"DATE"%3A20220712%7D%2C%7B"SELECT_REASON"%3A"02"%2C"IMPOSED_ACTION"%3Anull%2C"DISP_TYPE_TEXT"%3Anull%2C"COUNT"%3A412%2C"DATE"%3A20220712%7D%2C%7B"SELECT_REASON"%3A"05"%2C"IMPOSED_ACTION"%3Anull%2C"DISP_TYPE_TEXT"%3Anull%2C"COUNT"%3A332%2C"DATE"%3A20220712%7D%2C%7B"SELECT_REASON"%3A"06"%2C"IMPOSED_ACTION"%3Anull%2C"DISP_TYPE_TEXT"%3Anull%2C"COUNT"%3A60%2C"DATE"%3A20220712%7D%2C%7B"SELECT_REASON"%3A"07"%2C"IMPOSED_ACTION"%3Anull%2C"DISP_TYPE_TEXT"%3Anull%2C"COUNT"%3A258%2C"DATE"%3A20220712%7D%2C%7B"SELECT_REASON"%3A"09"%2C"IMPOSED_ACTION"%3Anull%2C"DISP_TYPE_TEXT"%3Anull%2C"COUNT"%3A300%2C"DATE"%3A20220712%7D%2C%7B"SELECT_REASON"%3A"12"%2C"IMPOSED_ACTION"%3Anull%2C"DISP_TYPE_TEXT"%3Anull%2C"COUNT"%3A242%2C"DATE"%3A20220712%7D%2C%7B"SELECT_REASON"%3A"13"%2C"IMPOSED_ACTION"%3Anull%2C"DISP_TYPE_TEXT"%3Anull%2C"COUNT"%3A282%2C"DATE"%3A20220712%7D%2C%7B"SELECT_REASON"%3A"14"%2C"IMPOSED_ACTION"%3Anull%2C"DISP_TYPE_TEXT"%3Anull%2C"COUNT"%3A2%2C"DATE"%3A20220712%7D%2C%7B"SELECT_REASON"%3A"15"%2C"IMPOSED_ACTION"%3Anull%2C"DISP_TYPE_TEXT"%3Anull%2C"COUNT"%3A180%2C"DATE"%3A20220712%7D%2C%7B"SELECT_REASON"%3A"16"%2C"IMPOSED_ACTION"%3Anull%2C"DISP_TYPE_TEXT"%3Anull%2C"COUNT"%3A30%2C"DATE"%3A20220712%7D%2C%7B"SELECT_REASON"%3A"17"%2C"IMPOSED_ACTION"%3Anull%2C"DISP_TYPE_TEXT"%3Anull%2C"COUNT"%3A6%2C"DATE"%3A20220712%7D%5D%27
The rendered html doesn't have the double quotes. How do I keep the browser from doing this?

How to convert image to string in angular

I am using angular 7 and need to upload image and send it to server to put it in database. So i wondering how to convert image into string and latter back in image so i can display it in app?
This SO answer explains how to convert an image into base64 encoded data.
You can use the HTML5 for it:
Create a canvas, load your image into it and then use toDataURL() to
get the base64 representation (actually, it's a data: URL but it
contains the base64-encoded image).
I don't think that's how you want to save your images though. Continue researching perhaps.

Is there a maximum length for HTML5 input?

I have an HTML text input to store the base64 string from an image canvas.
Apparently when I tried sending a long base64 string to the server, part of the string is not sent which results in grayed out image.

What is this image stored as?

I want to extract these telephone numbers from the website, either as an image or if possible as a string.
Here is an example from the website: Link
As you can see the telephone number is an image.
However I cant seem to view the image when I open the image source:
<img src="http://www.callmyname.sg/search/display_phone_number/VUhkVE1WOW5BV1lFWWxSbVhUdFRObGMzQlRBRU9nPT0=">
But when put into html and viewed in a browser, you can see the image fine.
It's a solution to prevent people like you from scraping their website :)
The url http://www.callmyname.sg/search/display_phone_number/VUhkVE1WOW5BV1lFWWxSbVhUdFRObGMzQlRBRU9nPT0= leads to a script that generates the image - probably based on the argument.
VUhkVE1WOW5BV1lFWWxSbVhUdFRObGMzQlRBRU9nPT0=
Since it ends with an equals sign, I tried to decode it as base64:
UHdTMV9nAWYEYlRmXTtTNlc3BTAEOg==
Now it looks even more like base64, so I tried another round:
PwS1_gfbTf];S6W70:
So it's clearly not plaintext (or not encoded with base64), which would be ridiculous and would let you extract the number this way. They either use some special cipher, or store the numbers in database with this as identifier.
I don't think you can steal the phone number easily, only using OCR perhaps.
When you visit the URL, you will get garbage, since they do not send proper MIME header
�PNG IHDR�,���tRNS���7X}4IDATx���_HZo�g�� E��p��l��EHTx!]�DtQ�M�.x3��.dx�*b]Dl"]�D���bQq.B����Z2$��:ȡ�wq��9�s���Cx>W�}���ٳ��ڶ����]���Ǐ�/_���ݿ���ahh���\q����������555�=���*�"�*�*�f�����}uu�e�d2���o����?00p����J%ȴds���BB�˲�`�`0RJy����n�{cc�e�H$b�ۻ����(�~�_����A4�Z��_�V|��J�w�����t:��333.��ƕ������+^����L`���֑��W��3�X�" y���$p'U"��F���y���z&�ioo��萟�*� ����\�L&Sx����p�e���ׯ_R��y�J%�~����|qq��|e�Z%:�J�{��q��nW�ՉD"�J��~�n4��������̔Ty���qF���>BwGa�z����������8��ߡc�f��B�>!�Ub�N�s���|�F�^/B���Lj��i��NfJ��͛D"����� o!t��`����fvv�eم��V���D)�����x���d2966&�n� ^,0O4��(!D��l�h46�-�~��Tً>B�"�Q�>,�P��ok#U \�BU,�P���=G SA+GIEND�B`�
but it's really just ordinary PNG image:
img http://www.callmyname.sg/search/display_phone_number/VUhkVU5scGlBV1lDWWdFelVEUUhZQWRvQlRZR013PT0=
It's a PNG image, but the server doesn't specify the right content header. It tells your browser that is't an html page in UTF-8 encoding, so you just see some garbage (including the letters PNG at the start).
The <img> tag though doesn't know how to display text so it just tries to load it as an image (and with success).
I don't see a way to extract the numbers in any other way than just reading the image. Because it contains only numbers and will have a similar format all the time, maybe you can find a simple way to parse it instead of using a full fledged OCR library.
It's actually a png-file, generated by a computer before being displayed. You can reference it fine from any other page though, and you should also be able to download it easily (right click, save as ...) Note: I tested this, make sure you save the image with the extension .png and not .html which it will default to.
<img src="http://www.callmyname.sg/search/display_phone_number/QkNOVE1RODNBV1lDWWdVM1V6ZFZNZ1JyRFQ0Rk1BPT0=">

How do I displayed Json into a text view with correct identation in cocos2d/cocos2dx?

When I try to show the JSON string, the indentation is gone and very ugly.
Is there a way to make it look better?
As you stated in a comment : the JSON string looks good in a browser. That is propably (I'm 99% sure) because most browsers will recognize the content as JSON and display it nicely, in an easier to read form. But in its core, the JSON string is just a set of characters, without any special whitespace characters like /n or /t to indicate newlines or tabs.
So to answear your question : in order to display your JSON string similarily to what you see in your browser, you'd have to parse and format it yourself.
If you are using a CCLabel to display it, you could subclass it creating a JSONLabel which would format a string given in its constructor the way that you like it.