magick

Generating Header Images for Blog

Inspired by Sense-Si, the process fills in text into a HTML page and uses a PhantomJS (on a docker container) and takes a screenshot. I wanted to see if I can make these in a simpler way with other tools I currently use already.

Trying out with Image Magick

First, lets download the image

wget -O header-plain.jpg "https://source.unsplash.com/featured/1200x630/?mountains"

single command but overflows

echo -n 'How to generate caption images with ImageMagick?' | composite -background rgba\(255,255,255,0.5\) -font BrushScriptI -pointsize 50 label:"@-" -channel rgba -alpha set  -gravity south -transparent-color white header-plain.jpg header-title1.jpg

But the text overflows when the image is of limited width

echo -n 'How to generate caption images with ImageMagick?'| convert -size 1200 -font BrushScriptI -pointsize 50 -gravity center -background rgba\(0,0,0,0.5\) -fill white caption:'@-' text.png
composite -channel rgba -alpha set -gravity south text.png header-plain.jpg header-title.jpg

This is how it looks with Image Magick

Trying with Cloudinary

Well, its kind of straight forward from the documentation to add text to an image.

Note: this is a dynamic image rendered off of Cloudinary servers, text can be passed in the URL. Text just needs to be encoded.

Trying with CSS

CSS 3 spec has become too powerful and once the layout is set, you need to take a screenshot from the generated style like in the first linked url.


Today I learnt - Image Magick scripts

I was generating logos for Git Notify’s Chrome Extension with the help of GoSpaces Tools. I have got a generic one in a decent sized banner. I had to crop off in the centre.

imagemagick to the rescue. but the args? A simple Google search solved it.

convert input.jpg -gravity center -crop 25x25+0+0 output.jpg

source: Image Magick Forum

Fred Weinhaus has put together lots of Image Magick scripts. One I was looking was to crop in the middle is called squareup.


Look here if you want to generate your own logos