⬜️ base64 image placeholders
Returns a base64 encoded transparent placeholder gif as Data URI
$ npm i plh
Requires ImageMagick
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==
You can also use plh
from within node:
var plh = require('plh')
var base64 = plh(3, 4)
// data:image/gif;base64,R0lGODlhAwAEAPAAAAAAAAAAACH5BAEAAAAALAAAAAADAAQAAAIDhI9WADs=
Sometimes base64 encoded placeholder images are handy. I made this so I could quickly nab aspect ratio specific placeholders.
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)"