Skip to content

dptole/fakeimg

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fake images generator

Build status Issue status NPM Version Downloads

When the client waits for the last moment to send the image files, and the layout is broken, you need a fake image to fill the gap.

Image providers

Example

const fakeimg = require('fakeimg')
    , fakeimg_pl = fakeimg.use('fakeimg.pl')
    , dummyimage = fakeimg.use('dummyimage')

const fakeimg_pl_object = fakeimg_pl({
  size: '400x200',
  background: '909090,255',
  foreground: 'fba,127',
  text: 'Fake image'
})

// https://fakeimg.pl/400x200/909090%2C255/fba%2C127/?text=Fake+image&font_name=yanone&font_size=50
console.log(fakeimg_pl_object.toString())

fakeimg_pl_object.download().then(http_response =>
  console.log('Fakeimg.pl download: Response status code ' + http_response.statusCode)
)

fakeimg_pl_object.downloadToFile('./fakeimg.pl.png').then(writestream =>
  console.log('Fakeimg.pl download: Writestream path', writestream.path)
)

const dummyimage_object = dummyimage({
  size: 300,
  text: 'Dummy image'
})

// https://dummyimage.com/300x300/cccccc/000000/?text=Dummy+image
console.log(dummyimage_object.toString())

dummyimage_object.download().then(http_response =>
  console.log('Dummyimage download: Response status code ' + http_response.statusCode)
)

dummyimage_object.downloadToFile('./dummyimage.png').then(writestream =>
  console.log('Dummyimage download: Writestream path', writestream.path)
)

License

MIT