EmojiOne Labs

version 3.1

toImage($str)

convert native unicode emoji and shortnames directly to images

This function is simply a shorthand for unicodeToImage($str) and shortnameToImage($str). First it will convert native unicode emoji directly to images and then convert any shortnames to images. This function can be useful to take mixed input and convert it directly to images if, for example, you have native unicode emoji stored in your database alongside shortnames.

Feel free to enter native unicode emoji and/or shortnames in the input below to test the conversion process. For a complete list of emoji and their shortnames check out emoji.codes.

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:

As of version 1.4.1 this library method has new syntax.
<?php
    namespace Emojione;

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

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

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

    if(isset($_POST['inputText'])) {
    echo $client->toImage($_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
    Emojione\Emojione::$imagePathPNG = './../assets/png/'; // defaults to jsdelivr's free CDN
    // ###############################################

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