Page 1 of 1

Pango + Color emoji

Posted: 2017-10-25T08:35:57-07:00
by kennytang852
Hi,

I'm trying to render color Emoji with PANGO and Noto Color Emoji Font.
However, the rendered Emoji become black & white.

Image

The Emoji is supposed to be like this:

Image

How to reproduce:

This is the command:

Code: Select all

convert -background white -size 600x50 \
pango:"<span font=\"Noto Color Emoji\" size=\"24576\">🦖</span> <span font=\"Noto Sans CJK TC\" size=\"24576\" color=\"green\">T-Rex in Traditional Chinese is 暴龍</span>" \
pango.jpg
This is the debug message:

Code: Select all

convert -debug all -background white -size 600x50 pango:"<span font=\"Noto Color Emoji\" size=\"24576\">🦖</span> <span font=\"Noto Sans CJK TC\" size=\"24576\" color=\"green\">T-Rex in Traditional Chinese is 暴龍</span>" pango.jpg
2017-10-25T23:33:33+08:00 0:00.000 0.000u 6.8.9 Configure convert[14093]: utility.c/ExpandFilenames/945/Configure
  Command line: convert {-debug} {all} {-background} {white} {-size} {600x50} {pango:<span font="Noto Color Emoji" size="24576">🦖</span> <span font="Noto Sans CJK TC" size="24576" color="green">T-Rex in Traditional Chinese is 暴龍</span>} {pango.jpg}
2017-10-25T23:33:33+08:00 0:00.000 0.000u 6.8.9 Configure convert[14093]: configure.c/GetConfigureOptions/679/Configure
  Searching for configure file: "/usr/share/ImageMagick-6/colors.xml"
2017-10-25T23:33:33+08:00 0:00.000 0.000u 6.8.9 Configure convert[14093]: configure.c/GetConfigureOptions/679/Configure
  Searching for configure file: "/usr/lib/x86_64-linux-gnu/ImageMagick-6.8.9//config-Q16/colors.xml"
2017-10-25T23:33:33+08:00 0:00.000 0.000u 6.8.9 Configure convert[14093]: configure.c/GetConfigureOptions/679/Configure
  Searching for configure file: "/etc/ImageMagick-6/colors.xml"
2017-10-25T23:33:33+08:00 0:00.000 0.000u 6.8.9 Configure convert[14093]: configure.c/GetConfigureOptions/679/Configure
  Searching for configure file: "/usr/share/doc/ImageMagick-6/colors.xml"
2017-10-25T23:33:33+08:00 0:00.000 0.000u 6.8.9 Configure convert[14093]: configure.c/GetConfigureOptions/679/Configure
  Searching for configure file: "/root/.config/ImageMagick/colors.xml"
2017-10-25T23:33:33+08:00 0:00.000 0.000u 6.8.9 Configure convert[14093]: configure.c/GetConfigureOptions/679/Configure
  Searching for configure file: "/root/.magick/colors.xml"
2017-10-25T23:33:33+08:00 0:00.000 0.000u 6.8.9 Configure convert[14093]: color.c/LoadColorCache/2181/Configure
  Loading color file "/etc/ImageMagick-6/colors.xml" ...
2017-10-25T23:33:33+08:00 0:00.000 0.000u 6.8.9 Configure convert[14093]: configure.c/GetConfigureOptions/679/Configure
  Searching for configure file: "/usr/share/ImageMagick-6/coder.xml"
2017-10-25T23:33:33+08:00 0:00.000 0.000u 6.8.9 Configure convert[14093]: configure.c/GetConfigureOptions/679/Configure
  Searching for configure file: "/usr/lib/x86_64-linux-gnu/ImageMagick-6.8.9//config-Q16/coder.xml"
2017-10-25T23:33:33+08:00 0:00.000 0.000u 6.8.9 Configure convert[14093]: configure.c/GetConfigureOptions/679/Configure
  Searching for configure file: "/etc/ImageMagick-6/coder.xml"
2017-10-25T23:33:33+08:00 0:00.000 0.000u 6.8.9 Configure convert[14093]: configure.c/GetConfigureOptions/679/Configure
  Searching for configure file: "/usr/share/doc/ImageMagick-6/coder.xml"
2017-10-25T23:33:33+08:00 0:00.000 0.000u 6.8.9 Configure convert[14093]: configure.c/GetConfigureOptions/679/Configure
  Searching for configure file: "/root/.config/ImageMagick/coder.xml"
2017-10-25T23:33:33+08:00 0:00.000 0.000u 6.8.9 Configure convert[14093]: configure.c/GetConfigureOptions/679/Configure
  Searching for configure file: "/root/.magick/coder.xml"
2017-10-25T23:33:33+08:00 0:00.000 0.000u 6.8.9 Configure convert[14093]: coder.c/LoadCoderCache/799/Configure
  Loading coder configuration file "/etc/ImageMagick-6/coder.xml" ...
2017-10-25T23:33:33+08:00 0:00.000 0.000u 6.8.9 Module convert[14093]: module.c/OpenModule/1275/Module
  Searching for module "PANGO" using filename "pango.la"
2017-10-25T23:33:33+08:00 0:00.000 0.000u 6.8.9 Module convert[14093]: module.c/GetMagickModulePath/561/Module
  Searching for coder module file "pango.la" ...
2017-10-25T23:33:33+08:00 0:00.000 0.000u 6.8.9 Module convert[14093]: module.c/OpenModule/1284/Module
  Opening module at path "/usr/lib/x86_64-linux-gnu/ImageMagick-6.8.9//modules-Q16/coders/pango.la"
2017-10-25T23:33:33+08:00 0:00.010 0.000u 6.8.9 Module convert[14093]: module.c/OpenModule/1311/Module
  Method "RegisterPANGOImage" in module "PANGO" at address 0x7f78f1be10e0
2017-10-25T23:33:33+08:00 0:00.010 0.000u 6.8.9 Module convert[14093]: module.c/OpenModule/1325/Module
  Method "UnregisterPANGOImage" in module "PANGO" at address 0x7f78f1be11a0
2017-10-25T23:33:33+08:00 0:00.010 0.000u 6.8.9 Policy convert[14093]: policy.c/IsRightsAuthorized/574/Policy
  Domain: Coder; rights=Read; pattern="PANGO" ...
2017-10-25T23:33:33+08:00 0:00.010 0.000u 6.8.9 Resource convert[14093]: resource.c/AcquireMagickResource/279/Resource
  Area: 240KB/240KB/1.0241GB
2017-10-25T23:33:33+08:00 0:00.010 0.000u 6.8.9 Resource convert[14093]: resource.c/AcquireMagickResource/279/Resource
  Memory: 240KB/234KiB/488.3MiB
2017-10-25T23:33:33+08:00 0:00.010 0.000u 6.8.9 Cache convert[14093]: cache.c/OpenPixelCache/3588/Cache
  open <span font="Noto Color Emoji" size="24576">🦖</span> <span font="Noto Sans CJK TC" size="24576" color="green">T-Rex in Traditional Chinese is 暴龍</span>[0] (Heap Memory, 600x50 234KiB)
2017-10-25T23:33:33+08:00 0:00.010 0.000u 6.8.9 Resource convert[14093]: resource.c/AcquireMagickResource/279/Resource
  Memory: 120KB/352KiB/488.3MiB
2017-10-25T23:33:33+08:00 0:00.010 0.000u 6.8.9 Resource convert[14093]: resource.c/RelinquishMagickResource/862/Resource
  Memory: 120KB/234KiB/488.3MiB
2017-10-25T23:33:33+08:00 0:00.010 0.000u 6.8.9 Resource convert[14093]: resource.c/RelinquishMagickResource/862/Resource
  Map: 120KB/16EiB/976.7MiB
2017-10-25T23:33:33+08:00 0:00.040 0.020u 6.8.9 Resource convert[14093]: resource.c/RelinquishMagickResource/862/Resource
  Memory: 120KB/117KiB/488.3MiB
2017-10-25T23:33:33+08:00 0:00.040 0.020u 6.8.9 Module convert[14093]: module.c/OpenModule/1275/Module
  Searching for module "JPEG" using filename "jpeg.la"
2017-10-25T23:33:33+08:00 0:00.040 0.020u 6.8.9 Module convert[14093]: module.c/GetMagickModulePath/561/Module
  Searching for coder module file "jpeg.la" ...
2017-10-25T23:33:33+08:00 0:00.040 0.020u 6.8.9 Module convert[14093]: module.c/OpenModule/1284/Module
  Opening module at path "/usr/lib/x86_64-linux-gnu/ImageMagick-6.8.9//modules-Q16/coders/jpeg.la"
2017-10-25T23:33:33+08:00 0:00.040 0.020u 6.8.9 Module convert[14093]: module.c/OpenModule/1311/Module
  Method "RegisterJPEGImage" in module "JPEG" at address 0x7f78edd926a0
2017-10-25T23:33:33+08:00 0:00.040 0.020u 6.8.9 Module convert[14093]: module.c/OpenModule/1325/Module
  Method "UnregisterJPEGImage" in module "JPEG" at address 0x7f78edd928b0
2017-10-25T23:33:33+08:00 0:00.040 0.020u 6.8.9 Policy convert[14093]: policy.c/IsRightsAuthorized/574/Policy
  Domain: Coder; rights=Write; pattern="JPG" ...
2017-10-25T23:33:33+08:00 0:00.040 0.030u 6.8.9 Policy convert[14093]: policy.c/IsRightsAuthorized/574/Policy
  Domain: Path; rights=Write; pattern="pango.jpg" ...
2017-10-25T23:33:33+08:00 0:00.040 0.030u 6.8.9 Policy convert[14093]: policy.c/IsRightsAuthorized/574/Policy
  Domain: Path; rights=Write; pattern="pango.jpg" ...
2017-10-25T23:33:33+08:00 0:00.040 0.030u 6.8.9 Coder convert[14093]: jpeg.c/WriteJPEGImage/2180/Coder
  Image resolution: 0,0
2017-10-25T23:33:33+08:00 0:00.040 0.030u 6.8.9 Resource convert[14093]: resource.c/AcquireMagickResource/279/Resource
  Memory: 90KB/205KiB/488.3MiB
2017-10-25T23:33:33+08:00 0:00.040 0.030u 6.8.9 Resource convert[14093]: resource.c/RelinquishMagickResource/862/Resource
  Memory: 90KB/117KiB/488.3MiB
2017-10-25T23:33:33+08:00 0:00.040 0.030u 6.8.9 Coder convert[14093]: jpeg.c/WriteJPEGImage/2262/Coder
  Interlace: non-progressive
2017-10-25T23:33:33+08:00 0:00.040 0.030u 6.8.9 Coder convert[14093]: jpeg.c/WriteJPEGImage/2276/Coder
  Quality: 0
2017-10-25T23:33:33+08:00 0:00.040 0.030u 6.8.9 Coder convert[14093]: jpeg.c/WriteJPEGImage/2501/Coder
  Storage class: DirectClass
2017-10-25T23:33:33+08:00 0:00.040 0.030u 6.8.9 Coder convert[14093]: jpeg.c/WriteJPEGImage/2503/Coder
  Depth: 16
2017-10-25T23:33:33+08:00 0:00.040 0.030u 6.8.9 Coder convert[14093]: jpeg.c/WriteJPEGImage/2509/Coder
  Number of colors: unspecified
2017-10-25T23:33:33+08:00 0:00.040 0.030u 6.8.9 Coder convert[14093]: jpeg.c/WriteJPEGImage/2511/Coder
  JPEG data precision: 8
2017-10-25T23:33:33+08:00 0:00.040 0.030u 6.8.9 Coder convert[14093]: jpeg.c/WriteJPEGImage/2566/Coder
  Image colorspace is RGB
2017-10-25T23:33:33+08:00 0:00.040 0.030u 6.8.9 Coder convert[14093]: jpeg.c/WriteJPEGImage/2568/Coder
  Sampling factors: 2x2,1x1,1x1
2017-10-25T23:33:33+08:00 0:00.040 0.030u 6.8.9 Resource convert[14093]: resource.c/AcquireMagickResource/279/Resource
  Memory: 1.8KB/119KiB/488.3MiB
2017-10-25T23:33:33+08:00 0:00.040 0.030u 6.8.9 Resource convert[14093]: resource.c/RelinquishMagickResource/862/Resource
  Memory: 1.8KB/117KiB/488.3MiB
2017-10-25T23:33:33+08:00 0:00.040 0.030u 6.8.9 Resource convert[14093]: resource.c/RelinquishMagickResource/862/Resource
  Map: 1.8KB/16EiB/976.7MiB
2017-10-25T23:33:33+08:00 0:00.040 0.030u 6.8.9 Resource convert[14093]: resource.c/RelinquishMagickResource/862/Resource
  Memory: 1.8KB/115KiB/488.3MiB
2017-10-25T23:33:33+08:00 0:00.040 0.030u 6.8.9 Cache convert[14093]: cache.c/DestroyPixelCache/942/Cache
  destroy <span font="Noto Color Emoji" size="24576">🦖</span> <span font="Noto Sans CJK TC" size="24576" color="green">T-Rex in Traditional Chinese is 暴龍</span>[0]
2017-10-25T23:33:33+08:00 0:00.040 0.030u 6.8.9 Resource convert[14093]: resource.c/RelinquishMagickResource/862/Resource
  Memory: 240KB/16EiB/488.3MiB
The Unicode of the T-Rex Emoji is \u{1f996} (in case the character lost for whatever reason). The T-Rex Emoji is an Unicode 10 Emoji added recently. The Noto B&W Emoji doesn't support it so I'm pretty sure the Emoji was rendered with Noto Color Emoji. (The issue applies to old Emoji too.)

How may I render the Emoji with color?

Thanks a lot :) .

Version:

Code: Select all

lsb_release -a

No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 16.04.3 LTS
Release:	16.04
Codename:	xenial

Code: Select all

convert --version

Version: ImageMagick 6.8.9-9 Q16 x86_64 2017-07-31 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2014 ImageMagick Studio LLC
Features: DPC Modules OpenMP
Delegates: bzlib cairo djvu fftw fontconfig freetype jbig jng jpeg lcms lqr ltdl lzma openexr pangocairo png rsvg tiff wmf x xml zlib

Code: Select all

convert -list format | grep PANGO

    PANGO* PANGO     r--   Pango Markup Language (Pangocairo 1.38.1)

Re: Pango + Color emoji

Posted: 2017-10-25T09:08:54-07:00
by fmw42
Your IM version is over 100 versions old. Your Pango is old also. I am using IM 6.9.9.20 and pango @1.40.11_0. You might try upgrading. Also can you zip your font and post it to some free hosting service such as dropbox.com and put the URL here. That way we can try to test it on current version. Alternately, provide a link to the font.

Re: Pango + Color emoji

Posted: 2017-10-25T09:12:48-07:00
by fmw42
What is your platform? I am not sure those color fonts work on anything but Linux. Not Mac or Windows.

Re: Pango + Color emoji

Posted: 2017-10-25T09:22:24-07:00
by fmw42
I tried using 6.8.9.9 Q16 Mac OSX

Code: Select all

convert -background white -size 600x50 \
pango:"<span font=\"/Library/Fonts/NotoColorEmoji\" size=\"24576\">🦖</span>" \
pango.jpg
And do not even get the shape of your desired font.

In your code above, it just shows a square for the character. Is that correct or has it been changed from what you wanted for the character needed?

Re: Pango + Color emoji

Posted: 2017-10-25T09:38:45-07:00
by kennytang852
fmw42 wrote: 2017-10-25T09:08:54-07:00 Your IM version is over 100 versions old. Your Pango is old also. I am using IM 6.9.9.20 and pango @1.40.11_0. You might try upgrading. Also can you zip your font and post it to some free hosting service such as dropbox.com and put the URL here. That way we can try to test it on current version. Alternately, provide a link to the font.
I'm using Ubuntu v16.04 LTS.
apt-get install imagemagick said I have the latest version. Anyway, I'm installing from source following this guide: https://www.imagemagick.org/script/install-source.php

It seems I did something wrong.

Code: Select all

convert --version

convert: error while loading shared libraries: libMagickCore-7.Q16HDRI.so.4: cannot open shared object file: No such file or directory
I'm not able to run the code now.
I compared the character you provided will mine, the character is correct.

I'm using the latest Noto Color Emoji (placed in ~/.fonts)
https://github.com/googlei18n/noto-emoj ... rEmoji.ttf

And a config file placed in ~/.config/fontconfig/fonts.conf

Code: Select all

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
  <match target="scan">
    <test name="family">
      <string>Noto Color Emoji</string>
    </test>
    <edit name="scalable" mode="assign">
      <bool>true</bool>
    </edit>
    <edit name="pixelsize" mode="assign">
      <double>18</double>
    </edit>
  </match>

  <match>
    <test name="family"><string>sans-serif</string></test>
    <edit name="family" mode="prepend" binding="weak">
      <string>Noto Color Emoji</string>
    </edit>
  </match>

  <match>
    <test name="family"><string>serif</string></test>
    <edit name="family" mode="prepend" binding="weak">
      <string>Noto Color Emoji</string>
    </edit>
  </match>

  <match>
    <test name="family"><string>Apple Color Emoji</string></test>
    <edit name="family" mode="prepend" binding="strong">
      <string>Noto Color Emoji</string>
    </edit>
  </match>
</fontconfig>
And clear font cache

Code: Select all

fc-cache -fv

Re: Pango + Color emoji

Posted: 2017-10-25T09:41:00-07:00
by kennytang852
May I know what is the proper way to upgrade / install Imagemagick and PANGO?

Re: Pango + Color emoji

Posted: 2017-10-25T09:46:15-07:00
by fmw42
You may need the freetype 2.5 or higher delegate. But I have had no success with that on my Mac

See
https://github.com/googlei18n/noto-emoji/issues/36
https://www.freetype.org

FreeType 2.5

2013-06-19
FreeType 2.5 has been released. A major new feature is support for color embedded bitmaps (eg. color emoji), contributed by Behdad Esfahbod on behalf of Google. Additionally, Adobe's CFF engine is now the default, which makes a good reason to change from the 2.4.x to the 2.5.x series.

Re: Pango + Color emoji

Posted: 2017-10-25T09:48:06-07:00
by fmw42
kennytang852 wrote: 2017-10-25T09:41:00-07:00 May I know what is the proper way to upgrade / install Imagemagick and PANGO?
Sorry I do not know about installing on Linux. See

http://www.imagemagick.org/script/download.php
http://www.imagemagick.org/script/insta ... e.php#unix
http://www.imagemagick.org/script/advan ... lation.php


If you install from source, you will need to install all your needed delegates manually and before installing ImageMagick.

On Linux, it is best to use some RPM.

Re: Pango + Color emoji

Posted: 2017-10-25T20:49:36-07:00
by kennytang852
fmw42 wrote: 2017-10-25T09:48:06-07:00
kennytang852 wrote: 2017-10-25T09:41:00-07:00 May I know what is the proper way to upgrade / install Imagemagick and PANGO?
Sorry I do not know about installing on Linux. See

http://www.imagemagick.org/script/download.php
http://www.imagemagick.org/script/insta ... e.php#unix
http://www.imagemagick.org/script/advan ... lation.php


If you install from source, you will need to install all your needed delegates manually and before installing ImageMagick.

On Linux, it is best to use some RPM.
I upgraded my server & ImageMagick. These are the version numbers now:

Code: Select all

// Ubuntu Version
Distributor ID:	Ubuntu
Description:	Ubuntu 17.10
Release:	17.10
Codename:	artful

// ImageMagick Version
Version: ImageMagick 6.9.7-4 Q16 x86_64 20170114 http://www.imagemagick.org
Copyright: © 1999-2017 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: Cipher DPC Modules OpenMP 
Delegates (built-in): bzlib djvu fftw fontconfig freetype jbig jng jpeg lcms lqr ltdl lzma openexr pangocairo png tiff wmf x xml zlib

// Pango Version
PANGO* PANGO     r--   Pango Markup Language (Pangocairo 1.40.6)
Still b&w

Image

Code: Select all

convert -background white -size 600x50 \
pango:"<span font=\"Noto Color Emoji\" size=\"24576\">🌏</span> <span font=\"Noto Sans CJK TC\" size=\"24576\" color=\"green\">Earth in Traditional Chinese is 地球</span>" \
pango.jpg

Re: Pango + Color emoji

Posted: 2017-10-25T22:00:29-07:00
by fmw42
Try a color background and see if that makes any difference. Just not white/gray/black. So for example try -background pink. Perhaps ImageMagick sees the white background and thinks the image should be grayscale.

If that works, try

Code: Select all

convert -background white -size 600x50 -set colorspace sRGB \
pango:"<span font=\"Noto Color Emoji\" size=\"24576\">🌏</span> <span font=\"Noto Sans CJK TC\" size=\"24576\" color=\"green\">Earth in Traditional Chinese is 地球</span>" \
pango.jpg

Re: Pango + Color emoji

Posted: 2017-10-25T23:27:41-07:00
by kennytang852
fmw42 wrote: 2017-10-25T22:00:29-07:00 Try a color background and see if that makes any difference. Just not white/gray/black. So for example try -background pink. Perhaps ImageMagick sees the white background and thinks the image should be grayscale.

If that works, try

Code: Select all

convert -background white -size 600x50 -set colorspace sRGB \
pango:"<span font=\"Noto Color Emoji\" size=\"24576\">🌏</span> <span font=\"Noto Sans CJK TC\" size=\"24576\" color=\"green\">Earth in Traditional Chinese is 地球</span>" \
pango.jpg
I tried the following commands with pink background but doesn't work.
It seems the emoji is semi-transparent when I render in PNG.

Code: Select all

convert -background pink -size 600x50 -set colorspace sRGB \
pango:"<span font=\"Noto Color Emoji\" size=\"24576\">🌏</span> <span font=\"Noto Sans CJK TC\" size=\"24576\" color=\"green\">Earth in Traditional Chinese is 地球</span>" \
pango.png
Image

Code: Select all

convert -background none -size 600x50 -set colorspace sRGB \
pango:"<span font=\"Noto Color Emoji\" size=\"24576\" background=\"pink\">🌏</span> <span font=\"Noto Sans CJK TC\" size=\"24576\" color=\"green\">Earth in Traditional Chinese is 地球</span>" \
pango.png
Image

Code: Select all

convert -background none -size 600x50 -set colorspace sRGB \
pango:"<span font=\"Noto Color Emoji\" size=\"24576\">🌏</span> <span font=\"Noto Sans CJK TC\" size=\"24576\" color=\"green\">Earth in Traditional Chinese is 地球</span>" \
pango.png
Image

Re: Pango + Color emoji

Posted: 2017-10-25T23:58:13-07:00
by fmw42
Sorry, I do not know what to tell you. I cannot test, since I am on a Mac and this supposedly works only on Linux. All my attempts on Mac, don't even give a grayscale font.