Add: node_modules
This commit is contained in:
21
app/node_modules/@jimp/png/LICENSE
generated
vendored
Normal file
21
app/node_modules/@jimp/png/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2018 Oliver Moran
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
35
app/node_modules/@jimp/png/README.md
generated
vendored
Normal file
35
app/node_modules/@jimp/png/README.md
generated
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
<div align="center">
|
||||
<img width="200" height="200"
|
||||
src="https://s3.amazonaws.com/pix.iemoji.com/images/emoji/apple/ios-11/256/crayon.png">
|
||||
<h1>@jimp/png</h1>
|
||||
<p>Default Jimp png encoder/decoder.</p>
|
||||
</div>
|
||||
|
||||
## Available Methods
|
||||
|
||||
### Jimp.deflateLevel
|
||||
|
||||
Sets the deflate level used when saving as PNG format (default is 9)
|
||||
|
||||
### Jimp.deflateStrategy
|
||||
|
||||
Sets the deflate strategy used when saving as PNG format (default is 3)
|
||||
|
||||
### Jimp.filterType
|
||||
|
||||
Sets the filter type used when saving as PNG format (default is automatic filters)
|
||||
|
||||
### Jimp.colorType
|
||||
|
||||
Sets the color type used when saving as PNG format (one of 0, 2, 4, 6)
|
||||
|
||||
### Filter Types
|
||||
|
||||
```js
|
||||
Jimp.PNG_FILTER_AUTO;
|
||||
Jimp.PNG_FILTER_NONE;
|
||||
Jimp.PNG_FILTER_SUB;
|
||||
Jimp.PNG_FILTER_UP;
|
||||
Jimp.PNG_FILTER_AVERAGE;
|
||||
Jimp.PNG_FILTER_PATH;
|
||||
```
|
162
app/node_modules/@jimp/png/dist/index.js
generated
vendored
Normal file
162
app/node_modules/@jimp/png/dist/index.js
generated
vendored
Normal file
@@ -0,0 +1,162 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
require("core-js/modules/es6.object.define-property");
|
||||
|
||||
var _pngjs = require("pngjs");
|
||||
|
||||
var _utils = require("@jimp/utils");
|
||||
|
||||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
|
||||
var MIME_TYPE = 'image/png'; // PNG filter types
|
||||
|
||||
var PNG_FILTER_AUTO = -1;
|
||||
var PNG_FILTER_NONE = 0;
|
||||
var PNG_FILTER_SUB = 1;
|
||||
var PNG_FILTER_UP = 2;
|
||||
var PNG_FILTER_AVERAGE = 3;
|
||||
var PNG_FILTER_PATH = 4;
|
||||
|
||||
var _default = function _default() {
|
||||
return {
|
||||
mime: _defineProperty({}, MIME_TYPE, ['png']),
|
||||
constants: {
|
||||
MIME_PNG: MIME_TYPE,
|
||||
PNG_FILTER_AUTO: PNG_FILTER_AUTO,
|
||||
PNG_FILTER_NONE: PNG_FILTER_NONE,
|
||||
PNG_FILTER_SUB: PNG_FILTER_SUB,
|
||||
PNG_FILTER_UP: PNG_FILTER_UP,
|
||||
PNG_FILTER_AVERAGE: PNG_FILTER_AVERAGE,
|
||||
PNG_FILTER_PATH: PNG_FILTER_PATH
|
||||
},
|
||||
hasAlpha: _defineProperty({}, MIME_TYPE, true),
|
||||
decoders: _defineProperty({}, MIME_TYPE, _pngjs.PNG.sync.read),
|
||||
encoders: _defineProperty({}, MIME_TYPE, function (data) {
|
||||
var png = new _pngjs.PNG({
|
||||
width: data.bitmap.width,
|
||||
height: data.bitmap.height
|
||||
});
|
||||
png.data = data.bitmap.data;
|
||||
return _pngjs.PNG.sync.write(png, {
|
||||
width: data.bitmap.width,
|
||||
height: data.bitmap.height,
|
||||
deflateLevel: data._deflateLevel,
|
||||
deflateStrategy: data._deflateStrategy,
|
||||
filterType: data._filterType,
|
||||
colorType: typeof data._colorType === 'number' ? data._colorType : data._rgba ? 6 : 2,
|
||||
inputHasAlpha: data._rgba
|
||||
});
|
||||
}),
|
||||
class: {
|
||||
_deflateLevel: 9,
|
||||
_deflateStrategy: 3,
|
||||
_filterType: PNG_FILTER_AUTO,
|
||||
_colorType: null,
|
||||
|
||||
/**
|
||||
* Sets the deflate level used when saving as PNG format (default is 9)
|
||||
* @param {number} l Deflate level to use 0-9. 0 is no compression. 9 (default) is maximum compression.
|
||||
* @param {function(Error, Jimp)} cb (optional) a callback for when complete
|
||||
* @returns {Jimp} this for chaining of methods
|
||||
*/
|
||||
deflateLevel: function deflateLevel(l, cb) {
|
||||
if (typeof l !== 'number') {
|
||||
return _utils.throwError.call(this, 'l must be a number', cb);
|
||||
}
|
||||
|
||||
if (l < 0 || l > 9) {
|
||||
return _utils.throwError.call(this, 'l must be a number 0 - 9', cb);
|
||||
}
|
||||
|
||||
this._deflateLevel = Math.round(l);
|
||||
|
||||
if ((0, _utils.isNodePattern)(cb)) {
|
||||
cb.call(this, null, this);
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets the deflate strategy used when saving as PNG format (default is 3)
|
||||
* @param {number} s Deflate strategy to use 0-3.
|
||||
* @param {function(Error, Jimp)} cb (optional) a callback for when complete
|
||||
* @returns {Jimp} this for chaining of methods
|
||||
*/
|
||||
deflateStrategy: function deflateStrategy(s, cb) {
|
||||
if (typeof s !== 'number') {
|
||||
return _utils.throwError.call(this, 's must be a number', cb);
|
||||
}
|
||||
|
||||
if (s < 0 || s > 3) {
|
||||
return _utils.throwError.call(this, 's must be a number 0 - 3', cb);
|
||||
}
|
||||
|
||||
this._deflateStrategy = Math.round(s);
|
||||
|
||||
if ((0, _utils.isNodePattern)(cb)) {
|
||||
cb.call(this, null, this);
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets the filter type used when saving as PNG format (default is automatic filters)
|
||||
* @param {number} f The quality to use -1-4.
|
||||
* @param {function(Error, Jimp)} cb (optional) a callback for when complete
|
||||
* @returns {Jimp} this for chaining of methods
|
||||
*/
|
||||
filterType: function filterType(f, cb) {
|
||||
if (typeof f !== 'number') {
|
||||
return _utils.throwError.call(this, 'n must be a number', cb);
|
||||
}
|
||||
|
||||
if (f < -1 || f > 4) {
|
||||
return _utils.throwError.call(this, 'n must be -1 (auto) or a number 0 - 4', cb);
|
||||
}
|
||||
|
||||
this._filterType = Math.round(f);
|
||||
|
||||
if ((0, _utils.isNodePattern)(cb)) {
|
||||
cb.call(this, null, this);
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets the color type used when saving as PNG format
|
||||
* @param {number} s color type to use 0, 2, 4, 6.
|
||||
* @param {function(Error, Jimp)} cb (optional) a callback for when complete
|
||||
* @returns {Jimp} this for chaining of methods
|
||||
*/
|
||||
colorType: function colorType(s, cb) {
|
||||
if (typeof s !== 'number') {
|
||||
return _utils.throwError.call(this, 's must be a number', cb);
|
||||
}
|
||||
|
||||
if (s !== 0 && s !== 2 && s !== 4 && s !== 6) {
|
||||
return _utils.throwError.call(this, 's must be a number 0, 2, 4, 6.', cb);
|
||||
}
|
||||
|
||||
this._colorType = Math.round(s);
|
||||
|
||||
if ((0, _utils.isNodePattern)(cb)) {
|
||||
cb.call(this, null, this);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
exports.default = _default;
|
||||
module.exports = exports.default;
|
||||
//# sourceMappingURL=index.js.map
|
1
app/node_modules/@jimp/png/dist/index.js.map
generated
vendored
Normal file
1
app/node_modules/@jimp/png/dist/index.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
147
app/node_modules/@jimp/png/es/index.js
generated
vendored
Normal file
147
app/node_modules/@jimp/png/es/index.js
generated
vendored
Normal file
@@ -0,0 +1,147 @@
|
||||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
|
||||
import { PNG } from 'pngjs';
|
||||
import { throwError, isNodePattern } from '@jimp/utils';
|
||||
var MIME_TYPE = 'image/png'; // PNG filter types
|
||||
|
||||
var PNG_FILTER_AUTO = -1;
|
||||
var PNG_FILTER_NONE = 0;
|
||||
var PNG_FILTER_SUB = 1;
|
||||
var PNG_FILTER_UP = 2;
|
||||
var PNG_FILTER_AVERAGE = 3;
|
||||
var PNG_FILTER_PATH = 4;
|
||||
export default (function () {
|
||||
return {
|
||||
mime: _defineProperty({}, MIME_TYPE, ['png']),
|
||||
constants: {
|
||||
MIME_PNG: MIME_TYPE,
|
||||
PNG_FILTER_AUTO: PNG_FILTER_AUTO,
|
||||
PNG_FILTER_NONE: PNG_FILTER_NONE,
|
||||
PNG_FILTER_SUB: PNG_FILTER_SUB,
|
||||
PNG_FILTER_UP: PNG_FILTER_UP,
|
||||
PNG_FILTER_AVERAGE: PNG_FILTER_AVERAGE,
|
||||
PNG_FILTER_PATH: PNG_FILTER_PATH
|
||||
},
|
||||
hasAlpha: _defineProperty({}, MIME_TYPE, true),
|
||||
decoders: _defineProperty({}, MIME_TYPE, PNG.sync.read),
|
||||
encoders: _defineProperty({}, MIME_TYPE, function (data) {
|
||||
var png = new PNG({
|
||||
width: data.bitmap.width,
|
||||
height: data.bitmap.height
|
||||
});
|
||||
png.data = data.bitmap.data;
|
||||
return PNG.sync.write(png, {
|
||||
width: data.bitmap.width,
|
||||
height: data.bitmap.height,
|
||||
deflateLevel: data._deflateLevel,
|
||||
deflateStrategy: data._deflateStrategy,
|
||||
filterType: data._filterType,
|
||||
colorType: typeof data._colorType === 'number' ? data._colorType : data._rgba ? 6 : 2,
|
||||
inputHasAlpha: data._rgba
|
||||
});
|
||||
}),
|
||||
class: {
|
||||
_deflateLevel: 9,
|
||||
_deflateStrategy: 3,
|
||||
_filterType: PNG_FILTER_AUTO,
|
||||
_colorType: null,
|
||||
|
||||
/**
|
||||
* Sets the deflate level used when saving as PNG format (default is 9)
|
||||
* @param {number} l Deflate level to use 0-9. 0 is no compression. 9 (default) is maximum compression.
|
||||
* @param {function(Error, Jimp)} cb (optional) a callback for when complete
|
||||
* @returns {Jimp} this for chaining of methods
|
||||
*/
|
||||
deflateLevel: function deflateLevel(l, cb) {
|
||||
if (typeof l !== 'number') {
|
||||
return throwError.call(this, 'l must be a number', cb);
|
||||
}
|
||||
|
||||
if (l < 0 || l > 9) {
|
||||
return throwError.call(this, 'l must be a number 0 - 9', cb);
|
||||
}
|
||||
|
||||
this._deflateLevel = Math.round(l);
|
||||
|
||||
if (isNodePattern(cb)) {
|
||||
cb.call(this, null, this);
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets the deflate strategy used when saving as PNG format (default is 3)
|
||||
* @param {number} s Deflate strategy to use 0-3.
|
||||
* @param {function(Error, Jimp)} cb (optional) a callback for when complete
|
||||
* @returns {Jimp} this for chaining of methods
|
||||
*/
|
||||
deflateStrategy: function deflateStrategy(s, cb) {
|
||||
if (typeof s !== 'number') {
|
||||
return throwError.call(this, 's must be a number', cb);
|
||||
}
|
||||
|
||||
if (s < 0 || s > 3) {
|
||||
return throwError.call(this, 's must be a number 0 - 3', cb);
|
||||
}
|
||||
|
||||
this._deflateStrategy = Math.round(s);
|
||||
|
||||
if (isNodePattern(cb)) {
|
||||
cb.call(this, null, this);
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets the filter type used when saving as PNG format (default is automatic filters)
|
||||
* @param {number} f The quality to use -1-4.
|
||||
* @param {function(Error, Jimp)} cb (optional) a callback for when complete
|
||||
* @returns {Jimp} this for chaining of methods
|
||||
*/
|
||||
filterType: function filterType(f, cb) {
|
||||
if (typeof f !== 'number') {
|
||||
return throwError.call(this, 'n must be a number', cb);
|
||||
}
|
||||
|
||||
if (f < -1 || f > 4) {
|
||||
return throwError.call(this, 'n must be -1 (auto) or a number 0 - 4', cb);
|
||||
}
|
||||
|
||||
this._filterType = Math.round(f);
|
||||
|
||||
if (isNodePattern(cb)) {
|
||||
cb.call(this, null, this);
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets the color type used when saving as PNG format
|
||||
* @param {number} s color type to use 0, 2, 4, 6.
|
||||
* @param {function(Error, Jimp)} cb (optional) a callback for when complete
|
||||
* @returns {Jimp} this for chaining of methods
|
||||
*/
|
||||
colorType: function colorType(s, cb) {
|
||||
if (typeof s !== 'number') {
|
||||
return throwError.call(this, 's must be a number', cb);
|
||||
}
|
||||
|
||||
if (s !== 0 && s !== 2 && s !== 4 && s !== 6) {
|
||||
return throwError.call(this, 's must be a number 0, 2, 4, 6.', cb);
|
||||
}
|
||||
|
||||
this._colorType = Math.round(s);
|
||||
|
||||
if (isNodePattern(cb)) {
|
||||
cb.call(this, null, this);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
//# sourceMappingURL=index.js.map
|
1
app/node_modules/@jimp/png/es/index.js.map
generated
vendored
Normal file
1
app/node_modules/@jimp/png/es/index.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
66
app/node_modules/@jimp/png/package.json
generated
vendored
Normal file
66
app/node_modules/@jimp/png/package.json
generated
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"@jimp/png@0.6.4",
|
||||
"C:\\Users\\ryuki\\TheDesk\\app"
|
||||
]
|
||||
],
|
||||
"_from": "@jimp/png@0.6.4",
|
||||
"_id": "@jimp/png@0.6.4",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-qv3oo6ll3XWVIToBwVC1wQX0MFKwpxbe2o+1ld9B4ZDavqvAHzalzcmTd/iyooI85CVDAcC3RRDo66oiizGZCQ==",
|
||||
"_location": "/@jimp/png",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "@jimp/png@0.6.4",
|
||||
"name": "@jimp/png",
|
||||
"escapedName": "@jimp%2fpng",
|
||||
"scope": "@jimp",
|
||||
"rawSpec": "0.6.4",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "0.6.4"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/@jimp/types"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/@jimp/png/-/png-0.6.4.tgz",
|
||||
"_spec": "0.6.4",
|
||||
"_where": "C:\\Users\\ryuki\\TheDesk\\app",
|
||||
"author": "",
|
||||
"dependencies": {
|
||||
"@jimp/utils": "^0.6.4",
|
||||
"core-js": "^2.5.7",
|
||||
"pngjs": "^3.3.3"
|
||||
},
|
||||
"description": "Default Jimp png encoder/decoder.",
|
||||
"devDependencies": {
|
||||
"@jimp/custom": "^0.6.4",
|
||||
"@jimp/test-utils": "^0.6.4"
|
||||
},
|
||||
"gitHead": "7c9d3c817cade88d4a20422be10670d3c1528429",
|
||||
"license": "MIT",
|
||||
"main": "dist/index.js",
|
||||
"module": "es/index.js",
|
||||
"name": "@jimp/png",
|
||||
"peerDependencies": {
|
||||
"@jimp/custom": ">=0.3.5"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "npm run build:node:production && npm run build:module",
|
||||
"build:debug": "npm run build:node:debug",
|
||||
"build:module": "cross-env BABEL_ENV=module babel src -d es --source-maps --config-file ../../babel.config.js",
|
||||
"build:node": "babel src -d dist --source-maps --config-file ../../babel.config.js",
|
||||
"build:node:debug": "cross-env BABEL_ENV=development npm run build:node",
|
||||
"build:node:production": "cross-env BABEL_ENV=production npm run build:node",
|
||||
"build:watch": "npm run build:node:debug -- -- --watch --verbose",
|
||||
"test": "cross-env BABEL_ENV=test mocha --require @babel/register",
|
||||
"test:coverage": "nyc npm run test",
|
||||
"test:watch": "npm run test -- --reporter min --watch"
|
||||
},
|
||||
"version": "0.6.4"
|
||||
}
|
159
app/node_modules/@jimp/png/src/index.js
generated
vendored
Normal file
159
app/node_modules/@jimp/png/src/index.js
generated
vendored
Normal file
@@ -0,0 +1,159 @@
|
||||
import { PNG } from 'pngjs';
|
||||
import { throwError, isNodePattern } from '@jimp/utils';
|
||||
|
||||
const MIME_TYPE = 'image/png';
|
||||
|
||||
// PNG filter types
|
||||
const PNG_FILTER_AUTO = -1;
|
||||
const PNG_FILTER_NONE = 0;
|
||||
const PNG_FILTER_SUB = 1;
|
||||
const PNG_FILTER_UP = 2;
|
||||
const PNG_FILTER_AVERAGE = 3;
|
||||
const PNG_FILTER_PATH = 4;
|
||||
|
||||
export default () => ({
|
||||
mime: { [MIME_TYPE]: ['png'] },
|
||||
|
||||
constants: {
|
||||
MIME_PNG: MIME_TYPE,
|
||||
PNG_FILTER_AUTO,
|
||||
PNG_FILTER_NONE,
|
||||
PNG_FILTER_SUB,
|
||||
PNG_FILTER_UP,
|
||||
PNG_FILTER_AVERAGE,
|
||||
PNG_FILTER_PATH
|
||||
},
|
||||
|
||||
hasAlpha: { [MIME_TYPE]: true },
|
||||
decoders: { [MIME_TYPE]: PNG.sync.read },
|
||||
encoders: {
|
||||
[MIME_TYPE]: data => {
|
||||
const png = new PNG({
|
||||
width: data.bitmap.width,
|
||||
height: data.bitmap.height
|
||||
});
|
||||
|
||||
png.data = data.bitmap.data;
|
||||
|
||||
return PNG.sync.write(png, {
|
||||
width: data.bitmap.width,
|
||||
height: data.bitmap.height,
|
||||
deflateLevel: data._deflateLevel,
|
||||
deflateStrategy: data._deflateStrategy,
|
||||
filterType: data._filterType,
|
||||
colorType:
|
||||
typeof data._colorType === 'number'
|
||||
? data._colorType
|
||||
: data._rgba
|
||||
? 6
|
||||
: 2,
|
||||
inputHasAlpha: data._rgba
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
class: {
|
||||
_deflateLevel: 9,
|
||||
_deflateStrategy: 3,
|
||||
_filterType: PNG_FILTER_AUTO,
|
||||
_colorType: null,
|
||||
|
||||
/**
|
||||
* Sets the deflate level used when saving as PNG format (default is 9)
|
||||
* @param {number} l Deflate level to use 0-9. 0 is no compression. 9 (default) is maximum compression.
|
||||
* @param {function(Error, Jimp)} cb (optional) a callback for when complete
|
||||
* @returns {Jimp} this for chaining of methods
|
||||
*/
|
||||
deflateLevel(l, cb) {
|
||||
if (typeof l !== 'number') {
|
||||
return throwError.call(this, 'l must be a number', cb);
|
||||
}
|
||||
|
||||
if (l < 0 || l > 9) {
|
||||
return throwError.call(this, 'l must be a number 0 - 9', cb);
|
||||
}
|
||||
|
||||
this._deflateLevel = Math.round(l);
|
||||
|
||||
if (isNodePattern(cb)) {
|
||||
cb.call(this, null, this);
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets the deflate strategy used when saving as PNG format (default is 3)
|
||||
* @param {number} s Deflate strategy to use 0-3.
|
||||
* @param {function(Error, Jimp)} cb (optional) a callback for when complete
|
||||
* @returns {Jimp} this for chaining of methods
|
||||
*/
|
||||
deflateStrategy(s, cb) {
|
||||
if (typeof s !== 'number') {
|
||||
return throwError.call(this, 's must be a number', cb);
|
||||
}
|
||||
|
||||
if (s < 0 || s > 3) {
|
||||
return throwError.call(this, 's must be a number 0 - 3', cb);
|
||||
}
|
||||
|
||||
this._deflateStrategy = Math.round(s);
|
||||
|
||||
if (isNodePattern(cb)) {
|
||||
cb.call(this, null, this);
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets the filter type used when saving as PNG format (default is automatic filters)
|
||||
* @param {number} f The quality to use -1-4.
|
||||
* @param {function(Error, Jimp)} cb (optional) a callback for when complete
|
||||
* @returns {Jimp} this for chaining of methods
|
||||
*/
|
||||
filterType(f, cb) {
|
||||
if (typeof f !== 'number') {
|
||||
return throwError.call(this, 'n must be a number', cb);
|
||||
}
|
||||
|
||||
if (f < -1 || f > 4) {
|
||||
return throwError.call(
|
||||
this,
|
||||
'n must be -1 (auto) or a number 0 - 4',
|
||||
cb
|
||||
);
|
||||
}
|
||||
|
||||
this._filterType = Math.round(f);
|
||||
|
||||
if (isNodePattern(cb)) {
|
||||
cb.call(this, null, this);
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
/**
|
||||
* Sets the color type used when saving as PNG format
|
||||
* @param {number} s color type to use 0, 2, 4, 6.
|
||||
* @param {function(Error, Jimp)} cb (optional) a callback for when complete
|
||||
* @returns {Jimp} this for chaining of methods
|
||||
*/ colorType(s, cb) {
|
||||
if (typeof s !== 'number') {
|
||||
return throwError.call(this, 's must be a number', cb);
|
||||
}
|
||||
|
||||
if (s !== 0 && s !== 2 && s !== 4 && s !== 6) {
|
||||
return throwError.call(this, 's must be a number 0, 2, 4, 6.', cb);
|
||||
}
|
||||
|
||||
this._colorType = Math.round(s);
|
||||
|
||||
if (isNodePattern(cb)) {
|
||||
cb.call(this, null, this);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
||||
});
|
BIN
app/node_modules/@jimp/png/test/images/dice.png
generated
vendored
Normal file
BIN
app/node_modules/@jimp/png/test/images/dice.png
generated
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 213 KiB |
BIN
app/node_modules/@jimp/png/test/images/options.png
generated
vendored
Normal file
BIN
app/node_modules/@jimp/png/test/images/options.png
generated
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 99 B |
99
app/node_modules/@jimp/png/test/png.test.js
generated
vendored
Normal file
99
app/node_modules/@jimp/png/test/png.test.js
generated
vendored
Normal file
@@ -0,0 +1,99 @@
|
||||
/* eslint-disable no-control-regex */
|
||||
|
||||
import { Jimp, getTestDir } from '@jimp/test-utils';
|
||||
import configure from '@jimp/custom';
|
||||
|
||||
import png from '../src';
|
||||
|
||||
const jimp = configure({ types: [png] }, Jimp);
|
||||
|
||||
describe('PNG', () => {
|
||||
const imagesDir = getTestDir(__dirname) + '/images';
|
||||
|
||||
it('load PNG', async () => {
|
||||
const image = await jimp.read(imagesDir + '/dice.png');
|
||||
|
||||
image.getPixelColor(10, 10).should.be.equal(0x00000000);
|
||||
image.getPixelColor(160, 80).should.be.equal(0x1c1cd4ff);
|
||||
image.getPixelColor(400, 250).should.be.equal(0x7e0c0cda);
|
||||
});
|
||||
|
||||
it('export PNG', async () => {
|
||||
const jgd = await jimp.read({
|
||||
width: 3,
|
||||
height: 3,
|
||||
data: [
|
||||
0xff0000ff,
|
||||
0xff0080ff,
|
||||
0xff00ffff,
|
||||
0xff0080ff,
|
||||
0xff00ffff,
|
||||
0x8000ffff,
|
||||
0xff00ffff,
|
||||
0x8000ffff,
|
||||
0x0000ffff
|
||||
]
|
||||
});
|
||||
const buffer = await jgd.getBufferAsync('image/png');
|
||||
|
||||
buffer.toString().should.match(/^.PNG\r\n/);
|
||||
});
|
||||
|
||||
it('should use png options', async () => {
|
||||
const jgd = await jimp.read({
|
||||
width: 20,
|
||||
height: 20,
|
||||
data: [
|
||||
0xff0000ff,
|
||||
0xff0080ff,
|
||||
0xff00ffff,
|
||||
0xff0080ff,
|
||||
0xff00ffff,
|
||||
0x8000ffff,
|
||||
0xff00ffff,
|
||||
0x8000ffff,
|
||||
0x0000ffff,
|
||||
0xff0000ff,
|
||||
0xff0080ff,
|
||||
0xff00ffff,
|
||||
0xff0080ff,
|
||||
0xff00ffff,
|
||||
0x8000ffff,
|
||||
0xff00ffff,
|
||||
0x8000ffff,
|
||||
0x0000ffff,
|
||||
0xff0000ff,
|
||||
0xff0080ff,
|
||||
0xff00ffff,
|
||||
0xff0080ff,
|
||||
0xff00ffff,
|
||||
0x8000ffff,
|
||||
0xff00ffff,
|
||||
0x8000ffff,
|
||||
0x0000ffff,
|
||||
0xff0000ff,
|
||||
0xff0080ff,
|
||||
0xff00ffff,
|
||||
0xff0080ff,
|
||||
0xff00ffff,
|
||||
0x8000ffff,
|
||||
0xff00ffff,
|
||||
0x8000ffff,
|
||||
0x0000ffff
|
||||
]
|
||||
});
|
||||
|
||||
const image = await jgd
|
||||
.deflateStrategy(0)
|
||||
.colorType(0)
|
||||
.getBufferAsync(Jimp.MIME_PNG);
|
||||
|
||||
const expected = await jimp.read(imagesDir + '/options.png');
|
||||
const expectedBuffer = await expected
|
||||
.deflateStrategy(0)
|
||||
.colorType(0)
|
||||
.getBufferAsync(Jimp.MIME_PNG);
|
||||
|
||||
image.should.be.deepEqual(expectedBuffer);
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user