1

I have created a script to create an image using GD and PHP. But when I run the code, it shows something like

����JFIF��>CREATOR: gd-jpeg v1.0 (using IJG JPEG v80), default quality ��C $.' ",#(7),01444'9=82<.342��C 2!!22222222222222222222222222222222222222222222222222��i"�� ���}!1AQa"q2���#B��R��$3br� %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz��������������������������������������������������������������������������� ���w!1AQaq"2�B���� #3R�br� $4�%�&'()56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz��������������������������������������������������������������������������?��(�����BT;$�o�s֠��K�/�q�3ʣ�8Ǯ~��R�j ���KE$쨥��G$������i$u= R����i�8lsZ���[vF�Rը��>�\IJ$�"�T��͡;�M;2��QE-U�ZH���4(���ͬ�)iG����䌖�\zs�L "���8e�Џ�@�$�QE ���hZ(��4��1bU�m����ZǞ�m��\��8 ���r3۵s��.e�h$!�pAl���#����9�I��JS],uqU���Uj*��%��.......

instead of correct things and browser also shows

The image “http://localhost/ttoe/ttoe.php?move=p” cannot be displayed because it contains errors.

Please help me!!

  • 12
    Try to add `header('Content-Type: image/jpeg');` before image output. – BlitZ Jun 04 '13 at 10:12
  • @CORRUPT You are too fast in giving answer in comments. :) – Yogesh Suthar Jun 04 '13 at 10:15
  • 1
    @YogeshSuthar if it is not a big deal, there is no honor to get reputation for it (IMHO). You still may post it as answer though, because I'm not providing any explaination with it. – BlitZ Jun 04 '13 at 10:17
  • @CORRUPT After adding `header('Content-Type: image/jpeg');`, browser shows: `The image “http://localhost/ttoe/ttoe.php?move=p” cannot be displayed because it contains errors.` – Gaurav Mishra Jun 06 '13 at 04:46
  • There might be errors, while you executing GD script to create it. Check response output with searching something like `error` via the seach bar. – BlitZ Jun 06 '13 at 06:02
  • You almost certainly have a BOM in your files. Please see http://stackoverflow.com/questions/3385982/the-image-cannot-be-displayed-because-it-contains-errors/17010390#17010390 – Danack Jun 09 '13 at 14:01

0 Answers0