Lulz on demand!

This here rofl crate, aptly named, is capable of the extraordinary feat of putting text on images. And not just still images: it does cover animated GIFs as well!

In other words, the crate can be used to create memes, which purists generally refer to as image macros.

extern crate rofl ; let engine = rofl :: Engine :: new ( "data/templates" , "data/fonts" ); let image_macro = rofl :: ImageMacro { template : "zoidberg" . into (), captions : vec ! [ rofl :: Caption :: text_at ( rofl :: VAlign :: Top , "Need an example?" ), rofl :: Caption :: text_at ( rofl :: VAlign :: Bottom , "Why not Zoidberg?" ), ], .. rofl :: ImageMacro :: default () }; let output = engine . caption ( image_macro ) ? ; let mut file = fs :: OpenOptions :: new (). write ( true ). open ( "zoidberg.png" ) ? ; file . write_all ( & * output ) ? ;

To create memes, you need two types of media resources (in addition to impeccable wit):

templates -- named images & animated GIFs that we can put text on

fonts to render the text with (like "Impact" or "Comic Sans" )

Those resources have to be provided to the captioning Engine .

In the simple above, they are just files contained within some directories. If you're doing something more complicated -- like a website where users can upload their own images -- you can implement your own Loader s for templates or even fonts.

A meme is defined by the ImageMacro structure. These can be deserialized from JSON or query strings if desired.

Go forth and meme!