Bash Script to Clip an Image to Text

Create a stand-out article header image for your programming article

Shinichi Okada
mkdir Awesome

--

The output from the command, cliptext -t “Bash script to clip an image to text” -w 1400 -e 900

Introduction

I like the text effect you see in this video. It creates a header image like the above and decided to make a Bash script for it. The video shows you how to clip an image to text using HTML and CSS. With my Bash script, you can create it from the terminal. I am going to use these images for my future articles with different background images and text.

Requirement

You need to install wkhtmltopdf/wkhtmltoimage. wkhtmltopdf/wkhtmltoimage are open source (LGPLv3) command line tools to render HTML into PDF/image formats using the Qt WebKit rendering engine.

I tried different methods, but I found wkhtmltopdf/wkhtmltoimage works reasonably well comparing to other options. Please note that wkhtmltopdf/wkhtmltoimageuse an old version of WebKit for its rendering engine, and it simply doesn’t support advanced CSS and Javascript.

I gave up using Firefox screenshot since it can’t handle CSS color: transparent.

Installation

--

--

Shinichi Okada
mkdir Awesome

A programmer and technology enthusiast with a passion for sharing my knowledge and experience. https://codewithshin.com