iamcal / emoji-data

Easy to parse data and spritesheets for emoji
MIT License
2.56k stars 301 forks source link

Some Facebook sheet emojis not recorded properly or at all in emoji.json, incorrect images. #143

Closed dhjw closed 4 months ago

dhjw commented 6 years ago

The Facebook sheet is 936x936 with the last row on the right and 24 in the second last row missing. So considering the sprite squares are 18 pixels that's 51*52-24 or 2628 emojis.

When I parse emoji.json skipping any that don't have "has_img_facebook", and for those with it including the skin_variations as well, I come out with just 1988 emojis.

Am I missing something? How can I find the references to the other 640 emojis on the sprite sheet?

Edit: By additionally processing the entries in emoji.json without has_img_facebook, and whose sheet_x and sheet_y I hadn't seen before, I found all but one, the hash key, supported by Facebook. See this image. This gets me to 2247 supported emojis found via emoji.json, which is still 381 shy of the data in the sprite sheet. Also most of these additional sprites in the sheet don't match what's seen on Facebook.

While I can appreciate that Facebook might change their images, I would have thought that every emoji seen in the sheet would have a corresponding entry in emoji.json. 640 extra unused emojis equates to a fair amount of potential wasted bandwidth.

dhjw commented 6 years ago

I scraped the full set of Facebook emojis by getting codepoints and descriptions here and using a PHP script based on this:

// size: 64 does not work, 128 only works for emojis from Unicode 10
// pixelRatio: values of 1, 1.5, 2 and 3 are working, possibly others as well, but not 2.5
// based on https://gist.github.com/Crissov/5bbf9704995317c20955ab2d0caf1045
function fb_emoji_url($codepoints,$size=16,$pixelRatio=1){
    $path="$pixelRatio/$size/$codepoints.png";
    $check=fb_checksum($path);
    return "https://www.facebook.com/images/emoji.php/v9/f$check/$path";
}
function fb_checksum($path,$base=317426846){
    for($pos=0; $pos<strlen($path); $pos++){
        $base=($base<<5)-$base+ord($path[$pos]);
        $base&=4294967295;
    }
    return base_convert($base&255,10,16);
}

Note for emojis ending in _fe0f you have to remove that string when retrieving the Facebook image.