Giter VIP home page Giter VIP logo

datamosh's Introduction

Datamosh License: MIT code style: prettier Build Status

datamosh_cover_2x

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

Install

$ npm install datamosh

Usage

const mosh = require("datamosh");

let imgBuff = await readFile("/full/path/to/image.png");

let moshedBuff = await mosh(imgBuff, "vaporwave");

Reading/Writing the moshed image

mosh("~/image.png", null, "~/moshed_image.png");

// because mode is null, a random mode will be chosen

Moshing a buffer with callbacks

const cb = (err, data) => {
  if (!err) writeFile("/path/to/out.gif", data);
};

mosh(imgBuff, "vana", cb);

Using multiple modes on a single image, applied with respect to order.

let moshedBuff = await mosh(imgBuff, ["fatcat", "vaporwave", "walter"]);

// ['vana', null, null] is also valid => ['vana', random, random]

API

mosh(source, mode?, cb|writePath?)

Takes input source Buffer/Path, returns an encoded Buffer with the applied modes.

  • mode, the mosh mode to apply to the source image. Multiple modes may be passed using an array of modes. Any null values are replaced with a random mode.
  • cb (err, data), when using callbacks.
  • writePath, the path to write the moshed image to.

Paths may use the tilde (~) character. Datamosh validates read and write paths, replacing tilde with the path to the home directory.

~/Desktop/moshes/ -> /home/youruser/Desktop/moshes

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.

const datamosh = require("datamosh");

function newMode(data, width, height) {
  // your cool code goes here!

  return data;
}

datamosh.MODES.newMode = newMode;

Example Images

mode:fatcat Fatcat was created by user @mster

mode:vaporwave Vaporwave was created by user @tlaskey

mode:blurbobb

mode:veneneux

Datamosh in the wild

Check out this list of awesome apps that use datamosh!

datamosh's People

Contributors

bjrint avatar dependabot[bot] avatar mster avatar sixem avatar tlaskey avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

datamosh's Issues

Feature: Seeds

Use seeds for randoms if provided -- will need to consider new mode param synthax?

Windows support

Introduction:

It would be nice to support the Windows OS, haha.

Details:

Support Window's style pathing i.e. C:\Users\YOURUSERNAME\Desktop

Work:

Change validation functions to either check os or replace \ with /

Bug: Veneneux mode breaks premoshed images

ISSUE:
Given an image that has already been moshed, running veneneux mode results in a corrupted image which in not viewable.

PROPOSED FIX:
Limit veneneux randomness assignment to a maximum 255.

Feature: New modes

Want to work with buffers to create some fun images?

Consider adding a mode to Datamosh!

Work

By adding a new mode, you will be creating a new file which exports a function that manipulates data extracted from a source image's bitmap. That may sound like a lot, but it'll essentially come down to basic iteration over a buffer. Starter code has been provided here.

Your mosh mode doesn't have to do anything specific -- if you think it's cool, we probably will too. Use your imagination and feel free to experiment!

Most of Datamosh's current modes overwrite existing Red/Green/Blue (RGB) pixel values with something random. If you get stuck check out some examples.

To test your mode, you have two options:

  1. (Preferred) Import it into Datamosh by adding an entery in mosh.MODES, here.
  2. Add it to the function property after you initialize Datamosh. Example code on how to do this can be found here.

On Contributing

There aren't many hoops to jump though.

Datamosh uses Prettier for linting and formatting. You will be approved for merging as long as your code passes npm test and only modifies what is needed for your contribution.

You can learn more about contributing in our Contributing document.

Contributing

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.