Is it possible to render multi-coloured emojis with ImageMagick? - text

I have a text that may contain emojis. I want to render it into JPEG image with RMagick (I can also use ImageMagick directly).
I was able to render only monochrome emojis with AndroidEmoji.ttf, but ImageMagick renders interrogation signs if I use AppleColorEmoji.ttf.
Here's how I do it:
require 'rmagick'
granite = Magick::ImageList.new('granite:')
canvas = Magick::ImageList.new
canvas.new_image(300, 100, Magick::TextureFill.new(granite))
input = "👠 👯👢 👣"
text = Magick::Draw.new
text.font = 'AppleColorEmoji.ttf'
text.pointsize = 20
text.gravity = Magick::CenterGravity
text.annotate(canvas, 0, 0, 0, 0, input)
canvas.write('result.jpg')
Is it possible to render coloured emojis with ImageMagick or is there another tool that can help?

You can use pango for text rendering (as of v6.7.6-3):
convert pango:'Hello! 😀How are you?' example.png
Produces this image (using v7.0.8-36)
See https://www.imagemagick.org/Usage/text/#pango for more details on how to use pango with ImageMagick
I'm on Ubuntu 18.04, using ImageMagick 7.0.8-36 (by compiling from source), which looks to have this configuration
Features: Cipher DPC HDRI OpenMP
Delegates (built-in): bzlib djvu fontconfig freetype jbig jng jpeg lcms lqr lzma openexr pangocairo png tiff wmf x xml zlib
And it looks like I'm using Pangocairo 1.40.14
$ convert -list format | grep -i pango
PANGO* r-- Pango Markup Language (Pangocairo 1.40.14)

I think you are out of luck... ImageMagick forum.
I suppose you could save all the glyphs as PNG files and append them together to make a "textspeak sentence"
convert smile.png StupidShoeThing.png arnie.png +append txtspeak.png

Related

How to add libgif as a package in yocto build

I am building yocto linux for embedded linux platform.
The build is successful and root file system is generated.
however libgif.so library is missing in the root filesystem.
I want libgif to be compiled and copied in my generated root filesystem (in /usr/lib/)
I tried adding giflib in local.conf
DISTRO_FEATURES_append = " giflib "
I expect the giflib to be compiled and copied in the /usr/lib in root filesystem. but it isn't.
If i add EXTRA_IMAGEDEPENDS += " giflib " and just build giflib with "bitbake giflib" then the giflib is compiled and generated at path
Build/tmp/work/aarch64-poky-linux/giflib/5.1.4-r0/build/lib/.libs/giflib.so
Thats not how it works, sorry.
Just building the package will not automagically install it into any rootfs
You have to tell bitbake that you want giflib to be included in your image. This is done by adding it to IMAGE_INSTALL of your custom image.
Adding it to DISTRO_FEATURES will probably have no effect at all, because that is only parsed for specific keywords.
This describes how to add something to a custom image: Custom images in Yocto. You can technically also go the local.conf routes mentioned in the paragraphs above the linked one, but that only hinders proper reproductibility. A bit more extensively, I explain it here.

Configuring PNG on ImageMagick on a Linux Server

I have been trying to run the following script on ImageMagick on a Linux server
convert resized.png -gravity Center -crop 1024X768+0+0 +repage flower.png
but have been hitting the following error:
convert: no decode delegate for this image format `PNG' # error/constitute.c/ReadImage/501.
convert: no images defined `flower.png' # error/convert.c/ConvertImageCommand/3212.
It looks like there is no delegate for PNG.
When I run:
identify -version
I get this result that shows that the PNG delegate is not installed:
Version: ImageMagick 6.9.0-4 Q16 x86_64 2015-01-25 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2015 ImageMagick Studio LLC
Features: DPC OpenMP
Delegates (built-in): bzlib freetype jpeg lcms tiff x zlib
As far as I can tell I have 'libpng' installed on my server.
How do I configure the PNG delegate for ImageMagick on my Linux server?
I have 'yum' installed but not 'apt-get'.
I did a lot more searching and found this answer.
It looks like ImageMagick did not know what library to look for.
I did a
locate libpng
and found that it was located in
/usr/lib64/
I was then able to run the commands on this page (from within the ImageMagick directory):
http://www.imagemagick.org/discourse-server/viewtopic.php?t=12366
./configure --enable-shared
make libdir=/usr/lib64
make libdir=/usr/lib64 install
./configure --enable-shared=yes --x-libraries=/usr/lib64 --without-perl
make
make install
Then running
identify -version
showed the following results:
Version: ImageMagick 6.9.0-4 Q16 x86_64 2015-01-30
http://www.imagemagick.org
Copyright: Copyright (C) 1999-2015 ImageMagick Studio LLC
Features: DPC OpenMP
Delegates (built-in): bzlib freetype jng jpeg lcms png tiff x zlib
which shows that PNG is now installed as a delegate.

Detecting file type in linux using file managers module for detection files?

Is there a way to extract in bash or python file description from file manager (ex. PCManFM in lubuntu or any other like nautilus), because when I use command "find" or python-magic pkg or filemagic pkg, i do not get so accurate results like in file manager?
(for ex. when file contains gif header and php code under it, only file manager recognizes the file as PHP script, and other as gif image)
found that mimetypes is good choice. Nautilus uses it's database in /usr/share/mime/, python-magic and filemagic use libmagic, find uses something else i guess.
Use the linux file command. I assume that file managers do the same (but I'm not 100% sure).
Examples:
file test.php
# output: test.php: PHP script, ASCII text
file test.gif
# output: test.gif: GIF image data, version 89a, 32 x 32
file /bin/ls
# output: /bin/ls: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=0x37cdd635587f519989044055623abff939002027, stripped

Error message converting PDF to JPG using imagemagick

Command:
convert small.pdf small.jpg
Output:
sh: gs: not found
convert: Postscript delegate failed `small.pdf': ZkQV.cache # error/pdf.c/ReadPDFImage/638.
convert: missing an image filename `small.jpg' # error/convert.c/ConvertImageCommand/2940.
Version:
Version: ImageMagick 6.6.0-4 2012-05-02 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2010 ImageMagick Studio LLC
Features: OpenMP
File used: http://www.relacweb.org/menuconferencia/menu/manual-memorias.pdf
On Linux.

cvLoadImage() fails whem loading *.jpg

I am trying to load a JPEG image using the cvLoadImage function and it fails. I get the output "image not loaded" (see the code below). However a window appears but no picture.
When trying to load png pictures the cvLoadImage operation is successful, i.e. the picture is presented in a window. Is there a package that I might be missing or what am I doing wrong?
I am using openCV on Ubuntu.
IplImage* img = NULL;
if( argc > 1 )
img = cvLoadImage(argv[1], 1);
if(img == 0)
printf("image not loaded \n")
Jpeg's load fine under OpenCv, I just checked it. Check to see that you got
the path correct
that the image you are loading is actually jpeg (or some kind of format actually supported by opencv.)
Actually the path is correct. I do not know if it is the way that I am building OpenCV that is incorrect:
General configuration ================================================
CXX: g++
CXXCPP: g++ -E
CPPFLAGS:
CXXFLAGS:
LDFLAGS:
Install path: /usr/local
Debug flags
Optimization flags -DNDEBUG -O3 -g -march=pentium4 -ffast-math -fomit-frame-pointer
MMX/SSE/SSE2/SSE3: -mmmx -msse -msse2 -msse3
OpenMP support: -fopenmp
External BLAS & LAPACK: no
HighGUI configuration ================================================
Windowing system --------------
Use Carbon / Mac OS X: no
Use gtk+ 2.x: yes
Use gthread: yes
Image I/O ---------------------
Use ImageIO / Mac OS X: no
Use libjpeg: yes
Use zlib: yes
Use libpng: yes
Use libtiff: no
Use libjasper: no
Use libIlmImf/OpenEXR: no
Video I/O ---------------------
Use QuickTime / Mac OS X: no
Use xine: no
Use gstreamer: no
Use ffmpeg: no
Use dc1394 & raw1394: no
Use v4l: yes
Use v4l2: yes
Use unicap: no
Wrappers for other languages =========================================
SWIG
Python no
Octave no
Additional build settings ============================================
Build demo apps yes
Now run make ...
I have rebuilt openCV as well as changed to root user when doing it instead of typing sudo. Now the jpg files can be opened. I might have lost the sudo 'somewhere in the installation of openCV procedure earlier on, which lead to some mismatch.

Resources