Menu

PNG binary showing up instead of a graph

2017-01-29
2017-01-29
  • Brian Edmond

    Brian Edmond - 2017-01-29

    I developed this on a Kubuntu desktop and it worked fine (http://data.moherp.org/rivers/niangua-gauge.png). I moved this up to my ISP (A2 Hosting, which also runs Linux servers) and I get a bunch of binary characters instead of the graph. Here is the page that fails: http://data.moherp.org/rivers/gauge/?gauge=06923250&hours=72

    �PNG  IHDR �l�wPLTE���U��~�IDATx����JA��o�Վ��VJ���!B� l����S��b�+x�{K��}ߤYP����y�zh�����4fF�W��nd��4 �R�$�p#aɺD��mD"���DT�E�qce.q85,�XEjq�$D� ".�M�8��{G�Z]�.m�c2���~�z��_���I��f1[O㓑[�[���M۫����d�ꯕm���ٝ&���\���ܞ����8�����S�O��R}���A����MV���֑��K�V�F7��J�E����7n>��H>���R�����/M"I�8)�B$�u�r��׭L��:��n-zUX�M"o��! ��ۧ���� ��N��g�aI]\]:�IEND�B

    I get no error messages on the page or in the server log. I'm guessing there must be a PHP setting or something that needs to be tweaked. GD appears to be enabled and functioning. I experimented with several settings but didn't have much luck in anything changing.

    I did load the sample code to see if it would work and it was fine (http://data.moherp.org/rivers/simpleplot.html). I did find some similar binary output behavior by searching this forum and Google, but in those cases the output was accompanied by error messages that could be corrected.

    Any ideas?

    Thanks! I love PHPlot so far!

    B

     

    Last edit: Brian Edmond 2017-01-29
    • Brian Edmond

      Brian Edmond - 2017-01-29

      UPDATE: I solved this problem.

      At first, I thought it was because I was using the EncodeImage() function to embed the PNG into my web page. So, I stripped out the HTML and only output the graph. Then, the graph showed an error message similar to "Could not find TrueType Font benjamingothic.ttf".

      So, I changed over to using the native GD fonts with the following commands:

      $plot->SetUseTTF(false);
      $plot->SetFontGD('title', 5); // instead of using SetFontTTF

      Thanks!

      B

       
  • Stu Warneski

    Stu Warneski - 2017-02-08

    Hi, I just posted a suggestion about modifying the manual page for SetUseTTF(). I had a similar issue when calling that method prior to setting a font filename. The logic seems backwards, like it should be "yes i want to enable TTF, and here is my default font filename", not "set the font name, and TTF is auto turned on".

     

Log in to post a comment.

MongoDB Logo MongoDB