node-js-image
Advanced tools
Comparing version 0.0.2 to 0.0.3
{ | ||
"name": "node-js-image", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "Manipulate Images in Node.js", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -9,2 +9,11 @@ const fs = require('fs') | ||
/** | ||
* @typedef { object } InitValues Three Dimensional Array | ||
* @property { Array1D } data | ||
* @property { number } width | ||
* @property { number } height | ||
* @property { number } channels | ||
* @property { number[] } shape | ||
*/ | ||
/** | ||
* @typedef {object} Options | ||
@@ -72,8 +81,10 @@ * @property {string} [fname] | ||
if (this.options && this.options.fname) { | ||
this.fromFile(this.options.fname) | ||
} | ||
if (this.options) { | ||
if (this.options.fname) { | ||
this.fromFile(this.options.fname) | ||
} | ||
if (this.options && this.options.buffer) { | ||
this.fromBuffer(this.options.buffer) | ||
if (this.options.buffer) { | ||
this.fromBuffer(this.options.buffer) | ||
} | ||
} | ||
@@ -101,2 +112,11 @@ } | ||
this.shape = [this.width, this.height, this.channels] | ||
/** @type { InitValues } */ | ||
this._initValues = { | ||
data: this.data, | ||
width: this.width, | ||
height: this.height, | ||
channels: this.channels, | ||
shape: this.shape | ||
} | ||
return this | ||
@@ -271,2 +291,6 @@ } | ||
/** | ||
* Rotate the Image clockwise by 90° | ||
* @returns { Image } | ||
*/ | ||
rotate () { | ||
@@ -299,2 +323,18 @@ if (this.isFlat) { this.pixels() } | ||
/** | ||
* Restore the Inital Image Values | ||
* @returns { Image } | ||
*/ | ||
restore () { | ||
const initValues = this._initValues | ||
if (initValues) { | ||
this.data = initValues.data | ||
this.width = initValues.width | ||
this.height = initValues.height | ||
this.channels = initValues.channels | ||
this.shape = initValues.shape | ||
} | ||
return this | ||
} | ||
/** | ||
* Helper Method for the Image Processing Methods | ||
@@ -301,0 +341,0 @@ * @private |
10721
316