Question

I am making the HTTP GET result for the image content from the server, initially I was getting the result as a garbled character set.

{�t�� �J��JQQT@@�ҥ�*((��^��{BB �� �^�F&��o���3s&�`@xf�~Cf��u����_�_^ dee��g�;/�������?r��Χ�3�@v�1p�|�=� ��.mm�{�>�?p���p�s���C]�q� B����N����}�!l`�/ �;o*�*y� ]�x��'O�S�W_�O���g=����|���D|�M-^��*�λt��U3���x�1��{Z��=��D�,\�,x�bܤ���Ç�-�����|�Z���6�5���r�~2 �#U��&�۷/�>��G�o[�(�}��Xu�@^�7�d`{��k��c��/�L�� ������s��9 �-��4ީ�g�q�6͜=��O�Bk#�)==��oݺ$p����St��Q:s6�s�rcj�|�/�4C�*�ϫ Zz��msk8|��M%_GV/YA�~GcƎ'�h��n�=:{�<ş9�A���� ~��y������޽{���� ��8w�%����k��~���6G}0�ТX��;z�' 4���}�.�U�RQ3��!���+V����DIN~DU�T�� ��y��G�2�p�g����P���y�g�r��mf=r�8}V�W{�Reh��|�}W]�[�+R��9���-[��jS� ����۵��CJ��T��������.�׎ߨ_����C�.�P��ܥ.�i#�2e�p��吝�BX|�i=͛5o� �K �~9W6l�L_~���hب1a��@�M�8�*W���y�&u�ҙ�V�Z��z�+W��J�/8km��П~�!�l�N_7h�}C��%㉏���G 4`Z�@�#�:���Xq���g����t�6R*\��E*�k�T����'s��:u�A�v�������1�裚uL� *Q�~(Ai/)�7��8w�"����s�����gu�؉�(��z�6�O��H&N�F��swF�:�a��+��0��h�������s�-]��j�f4���˯�U�!�шwT�ի��3i��zl�2�9%�P�p-Z~���D�FX�Y� ��C���v15��>�ѬY�X�xo��:�/�n)5��t6��e� �y�V:R�=6�7�6��ջ?��vIjҴ��X����Fm� ���e�SNi)��ȍƓ��[k@�-h�̸"o����?v�$�KժU髯�y�;Fw�X�����ؠ 4r��u���cNB\�[�S�PR�̝o�z�����-�Q�.o�o�p����R�QŊ�Ĝ7i�u���r�j~�Ҷ]�i��'_q+.�5��<����Qf�5j|�h��Ϝ�d7l�y�,�p ՝:wwIyL��&��h10���|���9���l0�����˩X�bT�쒥+ ���?�&��U���`l�JNݾ}�SF����&�ܥ�2W��.��{�-a:`#��ZP�Q}ɺ���sm��&G���95aTh`P�GЮ#�7��w[1�h��;���x`*�D�����@`�o7%h��u�͚!|D�#:�����xnF7���|��u\�Z�4��W��3g���`r���FhЂ0,\l�����p#0Ƈ�a֣>���:�w�Dp���g�����蘍ܗ�I;~������խ� =x��44�����]��8x���v0'�~M���&zT��3`0���b��@<�zz���(��sJ��6�\0[Pl����%�b<�%@��|�Hnh>�

Then I figured out that default content type of the page is "text/html", and make the content type to the "image/png" after that it's showing that, "it can't display the image because image contains error".

I am not sure is this related to the encoding issue because I am seeing the garbled characters ? after getting the image content does I need to decode/encode my result ?

Was it helpful?

Solution

Your data IS corrupt. The first 8 bytes of a valid PNG file are the decimal values 137 80 78 71 13 10 26 101. Bytes 2 - 4 are the ASCII characters PNG. Your file is something else or maybe just garbage.

BTW. Your question is poorly written as it lacks the relevant code. You'll get better results from improving your question than you will from adding a bounty.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top