Coder Social home page Coder Social logo

bitmap-project's Introduction

Bitmap CLI Application

This application can help perform a few basic image processing transformations on bitmap files (.bmp) with color depths of 8 or 24 bits and have a header field of 'BM'. Accepted bitmaps may have any width or height although smaller sized bitmaps are recommended for faster processing, there is a 100px by 100px sample image provided in the project.

###Installation & Getting Started:

  • Fork and or clone a copy of this repo and CD into the root file.
  • Run a NPM i -S (optional - dependencies we installed during the dev process).
  • Now that you have CD'd into the project and are at the root file you are able to run your transformations from your command line (see below for examples).

###Basic Commands:

  • node index.js [originalBitmapFile] [transformedBitmapFile] [transformation]
  • node index.js palette-bitmap.bmp ihm-palette-bitmap.bmp invertedhorizontalmirror
  • The above command will take the palette-bitmap.bmp file perform a 'invertedhorizontalmirror' transformation on it and create a new file named ihm-palette-bitmap.bmp

Note: The [originalBitmapFile] must be located in the assets folder, this is where all of your transformation files will be written to as well. Also, please include .bmp when creating your new file's name.

###Commands & Transformations Explained:

  • invert - inverts the bitmap's pixel array.
  • greyscale - modifies the bitmap's color table by converting the R, G and B value of each color to an average of the 3; thus converting the bitmap to greyscale.
  • redscale - modifies the bitmap's color table by converting the G value of each color's RGB to 0; thus converting the bitmap to redscale.
  • bluescale - modifies the bitmap's color table by converting the B value of each color's RGB to 0; thus converting the bitmap to bluescale.
  • greenscale - modifies the bitmap's color table by converting the R value of each color's RGB to 0; thus converting the bitmap to greenscale.
  • whitereplace - modifies the bitmap's color table by replacing all instances of white with black.
  • blackreplace - modifies the bitmap's color table by replacing all instances of black with white.
  • verticalmirror - modifies the second hald of bitmap's pixel array by duplicating the top half.
  • verticalmirrorinverted - modifies the second half of the bitmap's pixel array by duplicating the inverse of the top half.
  • horizontalmirror - modifies the second half of each line inside the bitmap's pixel array by duplicating the left half of the same line.
  • horizontalmirrorinverted - modifies the second half of each line inside the bitmap's pixel array by duplicating the inverse of the left half of the same line.

Note: There are 11 separate transformations, feel free to playaround with all of them and to chain multiple transformations on top each other. ex. node index.js palette-bitmap.bmp ihm-palette-bitmap.bmp invertedhorizontalmirror greyscale

###Technical Overview: My project is made up of 3 separate modules that live inside the lib folder(read,transform and write), the contents of which of which are exported. This project was an exercise in asynchronous callbacks, TDD (Test Driven Development), project organization and modularity among other things.

The file-reader.js module has an airity of 2 with expected inputs of a file path and a callback. The output is a buffer object, if there is a valid input of a (file path and function). If the parameter type/types are wrong or there is not 2 parameters an error will be thrown.

The file-transformer.js module has an airity of 3 with expected inputs of a buffer object, an array of transformations and a callback function. The output is an hexidecimally encoded buffer object that is ready to be written to a file, if there are valid inputs of an (buffer object, array of transformations and a callback function). If the parameter type/types are wrong or there is not 3 parameters an error will be thrown.

The file-writer.js module has an airity of 3 with expected inputs of an hexidecimally encoded buffer object, a file path string and a callback function. The expected result in a newly written file and a success message in your terminal, if there are valid inputs of an (hexidecimally encoded buffer object, a file path string and a callback function). If the parameter type/types are wrong or there is not 3 parameters an error will be thrown.

bitmap-project's People

Contributors

brianbixby avatar katyoleary avatar

Watchers

James Cloos avatar

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.