JoyPixels Labs

version 8.0

unicodeToImage($str)

convert native unicode emoji directly to images

If you have native unicode emoji characters that you want to convert directly to images, you can use this function. It should be noted that once your input text has been converted to images it cannot be converted back using the provided functions.

For that reason, we recommend only converting input text to images when it's ready to display to the client. The better alternative, in our opinion, is to convert native unicode emoji to their corresponding shortname using toShort($str) for database storage.

Feel free to enter native unicode emoji in the input below to test the conversion process.

Note: Once you start dealing with native unicode characters server side, it's important to ensure that your web stack is set up to handle UTF-8 character encoding. That is outside of the scope of our demos, but a quick Google Search will guide you in the right direction.

Input:

Output:

PHP Snippet:

<?php
    namespace JoyPixels;

    // include the PHP library (if not autoloaded)
    require('./../lib/php/autoload.php');

    $client = new Client(new Ruleset());

    // ###############################################
    # Optional:
    # default is ignore ASCII smileys like :) but you can easily turn them on
    $client->ascii = true;
    
    # if you want to host the images somewhere else
    # you can easily change the default paths
    $client->imagePathPNG = './assets/png/';
    // ###############################################

    if(isset($_POST['inputText'])) {
    echo $client->unicodeToImage($_POST['inputText']);
    }
?>
      

 

As of version 1.4.1 the following implementation has been deprecated. It's included in the library for backwards compatibility but will be removed at a later date.
<?php
    // include the PHP library (if not autoloaded)
    require('./../lib/php/autoload.php');

    // ###############################################
    // Optional:
    // if you want to host the images somewhere else
    // you can easily change the default paths
    JoyPixels\JoyPixels::$imagePathPNG = './../assets/png/'; // defaults to jsdelivr's free CDN
    // ###############################################

    if(isset($_POST['inputText'])) {
    echo JoyPixels\JoyPixels::unicodeToImage($_POST['inputText']);
    }
?>