Created
July 1, 2020 14:58
-
-
Save equivalent/27d4abbb78ea991778316526f87fff94 to your computer and use it in GitHub Desktop.
wkhtmltoimage / IMGKit gem UTF-8 test of Chinese and Arabic characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# IMGKit lib is a Ruby wrapper around wkhtmltoimage | |
# | |
# * https://github.com/csquared/IMGKit | |
# * https://wkhtmltopdf.org/ | |
# | |
class Html2image | |
def call | |
head = '<head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></head>' | |
div = "<div class='ping'>Pong 读写汉字 - 学中文 ... ﺩ ﻁ ﺽ ﻙ ﻕ. ﻑ ﺙ ﺱ ﺹ ﺵ چ ﺥ ﺡ ﻩ. ڤ ﺫ ﺯ ﻅ ﺝ ﻍ ﻉ ﺓ. ﻡ ﻥ. ﻭ ﻝ ﺭ ﻱ ﻯ. ﺀ ﺃ ﺇ ﺅ ﺉ. ـِﻳ ـِ ـٍ. ـُﻭ ـُ ـٌ. ـَﺍ ✅</</div>" # randomly googled Chinese and Arabic characters, I have no idea what they mean | |
html = '<html>' + head +'<body><h1>Abc</h1><p>test</p>' + div +'</body></html>' | |
kit = IMGKit.new(html, :quality => 50) | |
file = kit.to_file('/tmp/file.jpg') | |
end | |
end | |
# Html2image.new.call |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Limit Height / Width