Skip to content

✨💾 Fun with image data! It's time to ḑ̸͉̣͙͈̱͚̣̓͜͝ą̶̖̞̣͍̤̭̪̖͓̲̆͘͠ț̷͇͙̉͌͒̍̀̆̓͝á̸͖͇̦̖͚̞̲̩̝̳̝̖͈͙̚̚͜͝ḿ̴̢̨̡͔̼͈̝̣̹̳̖̝̲́̊̆͗̆̏̄̕͠o̴̧̧̗͕̖̤̠͙̳͔̮̾̂̌̒͝͝ş̴̢̨̦̪̼̜̩̠̟͔̱̽́͊́̐̽̔̀͜͝͝h̸̯̱͕̭̘̳̣͎͈͉̮̟̃̇̋̈́́̀̔̅̉̎́̊̒͘ 💯✨

License

Notifications You must be signed in to change notification settings

tlaskey/datamosh

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Datamosh

Mess around with image data using buffers, create some interesting & artistic results, profit.

API

mosh ( options, cb )

  • options:

    • read: <string> | <Buffer> (Required)

      May be a string path to original supported image, or the Buffer of said image.

      Supported image types: .jpg, .jpeg, .png, .bmp, .tiff, .gif.

    • write: <string>

      Path to write the resulting image.

      If unspecified, the resulting image data will be returned as a Buffer.

    • mode: <string>

      The mode to choose when moshing the supplied image. If no mode is specified, it will be chosen at random.

      Current modes include: schifty, blurbobb, veneneux, vana, fatcat.

  • cb: function(error, data)

    The callback function, as datamosh is callback based.

    The image data will be returned as a Buffer if options.write is unspecified. Reference the following for examples on usage.

Example Code

/* 
  Using paths
*/
;(function jumpInThePit () {
  require('datamosh')(
    {
      read: '/path/to/read/in.gif',
      write: '/path/to/write/out.gif',
      mode: 'veneneux'
    },
    err => {
      if (err) return console.error(err)

      console.log('Moshing Completed!')
    }
  )
})()

/* 
  Using buffers directly 
*/
;(function boogieWoogieBuffer () {
  // can be done w/ async too!
  let read = require('fs').readFileSync
  let write = require('fs').writeFileSync

  let img = read('/path/to/read/in.jpg')
  require('datamosh')(
    {
      read: img
    },
    (err, moshedImg) => {
      if (err) return console.error(err)

      console.log('Moshing Completed!')
      write('/path/to/write/out.jpg', moshedImg)
    }
  )
})()

Custom Modes

Datamosh allows you to set custom moshing modes. As of v1.1.0, this may be acomplished by adding a mosh function to the MODES property.

For mosh function starter code, see the included template file located here.

/*
  Setting custom modes
*/
const datamosh = require('datamosh')
function myNewMode (image) {
  // actually does nothing to the image
  return image
}

datamosh.MODES.myNewMode = myNewMode
datamosh(/* ... */)

Datamosh in the wild

Check out this list of awesome apps that use datamosh!

Example Images

Original

cute_kibby

Moshed using schifty.

moshed_kibby

Original

cat

Moshed using fatcat.

cat_moshed2

Original

k_0

Moshed using veneneux.

k_0_moshed

About

✨💾 Fun with image data! It's time to ḑ̸͉̣͙͈̱͚̣̓͜͝ą̶̖̞̣͍̤̭̪̖͓̲̆͘͠ț̷͇͙̉͌͒̍̀̆̓͝á̸͖͇̦̖͚̞̲̩̝̳̝̖͈͙̚̚͜͝ḿ̴̢̨̡͔̼͈̝̣̹̳̖̝̲́̊̆͗̆̏̄̕͠o̴̧̧̗͕̖̤̠͙̳͔̮̾̂̌̒͝͝ş̴̢̨̦̪̼̜̩̠̟͔̱̽́͊́̐̽̔̀͜͝͝h̸̯̱͕̭̘̳̣͎͈͉̮̟̃̇̋̈́́̀̔̅̉̎́̊̒͘ 💯✨

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%