Mess around with image data using buffers, create some interesting & artistic results, profit.
-
-
May be a string path to original supported image, or the Buffer of said image.
Supported image types:
.jpg, .jpeg, .png, .bmp, .tiff, .gif
. -
Path to write the resulting image.
If unspecified, the resulting image data will be returned as a Buffer.
-
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
.
-
-
The callback function, as
datamosh
is callback based.The image
data
will be returned as a Buffer ifoptions.write
is unspecified. Reference the following for examples on usage.
/*
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)
}
)
})()
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(/* ... */)
Check out this list of awesome apps that use datamosh
!
- JanMichaelBot by user @Tlaskey
Original
Moshed using schifty
.
Original
Moshed using fatcat
.
Original
Moshed using veneneux
.