We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22683
    • 41 Posts
    How to use GD Library in modx..??

    I use modx 0.9.6.3 and enable GD Library in my webserver (xampp).

    I create snippet for show image from generate text use function ImageTTFText but not work?

    <?php
    header ("Content-type: image/png"); 
    $image = imagecreate (150, 20);
    $background = ImageColorAllocate ($image, 00, 00, 00);
    $white = ImageColorAllocate ($image, 255, 255, 255);
    ImageTTFText ($image, 8, 0, 0, 15, $white, "arial.ttf", "Straight");
    ImagePNG($image);
    ?>
    


    Result snippet :

    �PNG  ��� IHDR�����������W����PLTE������???���������___%��Z����IDATx�c`�� 0�00C�@���� � �.�)@�Ye ��a�� �!���"��dht��B"����cC*��b`kv`jowd``d`$�,v��@w Ph��P;cB#ď���f��l �\��{�Y�䚅 ژ�NZ@�X�jf S���mez�������IEND�B`�

    ::) i think i wrong send message for this forum , but can someone help me...


    Regards,

    Syu11
      • 22683
      • 41 Posts
      grin I am still learning php and modx.. eventually i can use GD library..

      I hope this bit of knowledge can help .. who have experienced the same problem as me.. laugh

      I change my snippet to be :
      <?php
      $image = imagecreate (150, 20);
      $background = ImageColorAllocate ($image, 00, 00, 00);
      $white = ImageColorAllocate ($image, 255, 255, 255);
      ImageTTFText ($image, 8, 0, 0, 15, $white, "assets/files/arial.ttf", "Straight");
      ImagePNG($image,"image.png");
      ImageDestroy($image);
      
      $output = '<img src="image.png" border=0>';
      
      return $output;
      ?>
      
        • 3749
        • 24,544 Posts
        I’m glad you got it figured out. Thanks for reporting back so others can use the information. smiley
          Did I help you? Buy me a beer
          Get my Book: MODX:The Official Guide
          MODX info for everyone: http://bobsguides.com/modx.html
          My MODX Extras
          Bob's Guides is now hosted at A2 MODX Hosting