Skip to content

Instantly share code, notes, and snippets.

@rtanglao
Last active September 17, 2023 20:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rtanglao/0d0e9c5a9dbd7ffae7825acd5544140c to your computer and use it in GitHub Desktop.
Save rtanglao/0d0e9c5a9dbd7ffae7825acd5544140c to your computer and use it in GitHub Desktop.
# convert pango:'a🤳Hello! 😀How are you?' example.png # Selfie emoji is Unicdode Hex 1F933
require 'rmagick'
image = Magick::Image.read('pango:&#x1F933;The <b>bold</b> and <i>beautiful</i>').first
image.write('pango.png')
@rtanglao
Copy link
Author

  • if pango isn't installed as an imagemagick delegate you'll get an error like this:
irb(main):001:0> require 'rmagick'
=> true
irb(main):002:0> image = Magick::Image.read('pango:&#x1F933;The <b>bold</b> and 
<i>beautiful</i>').first
(irb):2:in `read': unable to open image '&#x1F933;The <b>bold</b> and <i>beautiful</i>': No such file or directory @ error/blob.c/OpenBlob/3569 (Magick::ImageMagickError)
	from (irb):2:in `<main>'
	from /Users/roland/.rubies/ruby-3.2.2/lib/ruby/gems/3.2.0/gems/irb-1.6.2/exe/irb:11:in `<top (required)>'
	from /Users/roland/.rubies/ruby-3.2.2/bin/irb:25:in `load'
	from /Users/roland/.rubies/ruby-3.2.2/bin/irb:25:in `<main>'

@rtanglao
Copy link
Author

As of September 2023, brew doesn't install the pango delegate

roland@gMBP ~ % identify -version
Version: ImageMagick 7.1.1-15 Q16-HDRI x86_64 21298 https://imagemagick.org
Copyright: (C) 1999 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC HDRI Modules OpenMP(5.0) 
Delegates (built-in): bzlib fontconfig freetype gslib heic jng jp2 jpeg jxl lcms lqr ltdl lzma openexr png ps raw tiff webp xml zlib
Compiler: gcc (4.2)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment