stevencl2000 has asked for the wisdom of the Perl Monks concerning the following question:

I have problems using GD module. Really hope that you could help. I have tried calling GD module using a simple cgi script, and it worked. But then, I tried on a more complicated script, where this script processes questions population, it will display characters like below, instead of bar charts.

&#8240;PNG IHDR&#65533;h&#382;Ã&#710;gPLTEÿÿÿÿ¿ÿÿÿx½ftR +NS@æÃ&#732;f 4IDATx&#339;í][&#8211;«*í)ä£FÃ&#8218;ª&#339;;íü +§rÃ&#402;CÃ¥U@)L³Ã&#65533;I' Ã&#8230;f Ã&#710;Ã&#65533;JáÃ&#8225;à +¹&#65533;&#8230;Ã&#8222;Ã&#65533;&#8230;¶iá"%Ã&#8225;ò@Ã&#8216;&Ã& +#8222;â¹@&#8211;vü¸4&#8212;Ã&#8217;ô&#339;hþ8) &#8249;g³[1] +[1][1][1][1][1]Ã&#8225;\Vhà¸Ã&#8230;àÃ&#8224;&#8217;x£&#8249;'V¨ +&#8218;&#353;è·&#8211;.&#339;k{Ã&#352;h&#8209;c]Ã&#8250;:¬¤ db +à¸@Ã&#8211;Â¥Ã&#8221;Ã&#8217;%iSº'ªàÃ&#339;@ðøí&#8220;Ã¥xpà +½Oÿrïê ¸¶+Có&#381;&#8249;´#Ã&#8222;(ù!ZC½÷ |H&#710;Ã&#8216 +;öQøÃ&#8225;ækÃ&#65533;&#8212;i>µe ¹&#710;)&#8222;Ã&#8218;w &#82 +16;ö½¢ä4§&#65533;.»°oÃ&#8224;cöG@°ZÃ&#65533;,jç÷G>&#65533 +;¡&0_Ã&#65533;2¦&#65533;Ã&#8216;0&#8230;&#338;&#8224;)d4L!£a Ã&# +382;ø&#710;&#382;á¤vÃ&#65533;þüêi6¼ñ&#8216;m÷&#8224;Ã&#65533 +;¯&#382;æÃ&#402;Ã&#65533;Ã&#8221;=D)¤þõÃ&#339;&#8240;&#339;n&# +338;Ã&#8224;uL!£a SÃ&#710;h&#732;BFÃ&#402;2¾^Ã&#8224;BÃ&#8218;ãp +çºÃ&#8218;qïàÃ&#8217;Bdâiüc&#8230;< ô5ò0Ã&#8221;qv#Q¿ä±Ã&# +8249;&#352;þ&#8226;9&#8211;¾¹Ã&#8482;&#376;Ã¥8&#8211;~pfO¬Bð^d&# +339;&#8218;S#D-Ã&#732;GÃ&#339;·9TÃ&#402;Zb{7&#353;¼ï&#8218;d&#381 +;M =Ã&#338;M$&#381;cÃ&#338;&#8250;[!NpDÃ&#8224;Y@Y'Dª)&#8250;NÃ&#822 +2;QÃ&#732;÷*¬Ã&#382;± Ã&#65533;Â¥o&#381;©cFpz%72L!áNBá.>&#8230; +ãÃ&#65533;üZp&#8240;m&#65533;þÃ&#8221;Ã&#8230;þL!£aD!H-2Ã&#352;a +X!&#710;Ã&#8250;+ùë0¨õ_Vï¼§0¢¡N ªû[Ã&#381;&#65533;(Ã&#8222 +;&#8364;¹Ã&#376;Ã&#339;ÿ&#8222;&#352;¸©o00&#8217;IEND®B`&#8218;

PLEASE HELP.

Edit by castaway, added tags to reduce mess, original has actual strange characters instead of HTML entities

Replies are listed 'Best First'.
Re: GD Module
by castaway (Parson) on May 18, 2004 at 10:58 UTC
    Hi, it's difficult to help without knowing what actual code you are using. That output looks like an actual PNG type image, which is perfectly legal for GD. I can only guess that your cgi script is not outputting the correct HTTP headers to tell the browser that the data is a PNG.

    Please post your actual code, then we can help.

    C.

Re: GD Module
by Abigail-II (Bishop) on May 18, 2004 at 11:51 UTC
    Edit by castaway, added tags to reduce mess, original has actual strange characters instead of HTML entities
    Yeah, but I strongly doubt the OP saw what's now being displayed. I don't belief a raw PNG file contains HTML entities for Unicode characters. The file might have started with 00/0PNG, but not with &#8240;PNG.

    Abigail

      Despite any editing I think the statistical chances of a script randomly producing /^.PNG....IHDH/ and not being a PNG being displayed as plain text in a browser secondary to missing Content-Type: image/png headers is about 0. To be pedantic it is perhaps 1/18446744073709551616 (256**8) FWIW which is not much.

      cheers

      tachyon