Skip to content

jongacnik/plh

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

plh

Returns a base64 encoded transparent placeholder gif as Data URI

$ npm i plh

Requires ImageMagick

CLI

Let's make a 1x1 pixel placeholder:

$ plh
# → data:image/gif;base64,R0lGODlhAQABAPAAAAAAAAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==

You can also pass in a width and height:

$ plh 10 50
# → data:image/gif;base64,R0lGODlhCgAyAPAAAAAAAAAAACH5BAEAAAAALAAAAAAKADIAAAIUhI+py+0Po5y02ouz3rz7D4biiBQAOw==

Node

You can also use plh from within node:

var plh = require('plh')
var base64 = plh(3, 4)
// → data:image/gif;base64,R0lGODlhAwAEAPAAAAAAAAAAACH5BAEAAAAALAAAAAADAAQAAAIDhI9WADs=

FAQ

Why?

Sometimes base64 encoded placeholder images are handy. I made this so I could quickly nab aspect ratio specific placeholders.

How?

The ImageMagick convert command is used to create a placeholder image which is piped into the base64 program and concated to a data uri prefix:

echo 'data:image/gif;base64,'"$(convert -size 1x1 xc:transparent gif:- | base64)"

About

⬜️ base64 image placeholders

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published