Project

text2image

0.0
The project is in a healthy, maintained state
text2image allows you to easily transform text into black-and-white images using the best available system fonts. Ideal for quick image generation from text data.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Runtime

 Project Readme

text2image

text2image is a Ruby library that transforms text into black-on-white images. It automatically detects system fonts and generates optimized images with configurable padding around the text.

Features

  • Multi-format Support: Convert text to png, jpg, bmp, or webp images.
  • Smart Padding: Calculates the bounding box of the text and adds uniform padding on all four sides.
  • Auto Font Detection: Automatically finds the best available system font using fontconfig.
  • Customizable: Options for font size, specific font paths, background/foreground colors, and padding width.

Requirements

This library requires ImageMagick and fontconfig to be installed on your system.

Linux (Ubuntu/Debian)

sudo apt update
sudo apt install imagemagick fontconfig

macOS

brew install imagemagick fontconfig

Installation

Add this line to your application's Gemfile:

gem 'text2image'

And then execute:

$ bundle install

Usage

Basic Usage

require 'text2image'

# Save text to an image file (default 10px padding)
Text2image.convert("Hello, World!", output: "hello.png")

# With custom options including padding and format
Text2image.convert("Ruby is Awesome", 
  output: "ruby.webp",
  font_size: 48,
  padding: 30,
  background: "#f0f0f0",
  foreground: "blue",
  format: "webp"
)

License

Copyright (c) 2008-2026 Rheehose (Rhee Creative). Released under the MIT License.