Add: node_modules
This commit is contained in:
21
app/node_modules/@jimp/plugin-cover/LICENSE
generated
vendored
Normal file
21
app/node_modules/@jimp/plugin-cover/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.
|
54
app/node_modules/@jimp/plugin-cover/README.md
generated
vendored
Normal file
54
app/node_modules/@jimp/plugin-cover/README.md
generated
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
<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/plugin-cover</h1>
|
||||
</div>
|
||||
|
||||
Scale the image so the given width and height keeping the aspect ratio. Some parts of the image may be clipped.
|
||||
|
||||
## Usage
|
||||
|
||||
- @param {number} w the width to resize the image to
|
||||
- @param {number} h the height to resize the image to
|
||||
- @param {number} alignBits (optional) A bitmask for horizontal and vertical alignment
|
||||
- @param {string} mode (optional) a scaling method (e.g. Jimp.RESIZE_BEZIER)
|
||||
- @param {function(Error, Jimp)} cb (optional) a callback for when complete
|
||||
|
||||
```js
|
||||
import jimp from 'jimp';
|
||||
|
||||
async function main() {
|
||||
const image = await jimp.read('test/image.png');
|
||||
|
||||
image.cover(150, 100);
|
||||
}
|
||||
|
||||
main();
|
||||
```
|
||||
|
||||
### Align modes
|
||||
|
||||
The following constants can be passed to `image.cover`:
|
||||
|
||||
```js
|
||||
Jimp.HORIZONTAL_ALIGN_LEFT;
|
||||
Jimp.HORIZONTAL_ALIGN_CENTER;
|
||||
Jimp.HORIZONTAL_ALIGN_RIGHT;
|
||||
|
||||
Jimp.VERTICAL_ALIGN_TOP;
|
||||
Jimp.VERTICAL_ALIGN_MIDDLE;
|
||||
Jimp.VERTICAL_ALIGN_BOTTOM;
|
||||
```
|
||||
|
||||
For example:
|
||||
|
||||
```js
|
||||
image.cover(250, 250, Jimp.HORIZONTAL_ALIGN_LEFT | Jimp.VERTICAL_ALIGN_TOP);
|
||||
image.cover(250, 250, Jimp.HORIZONTAL_ALIGN_RIGHT | Jimp.VERTICAL_ALIGN_BOTTOM);
|
||||
```
|
||||
|
||||
Default align mode for `image.cover` is:
|
||||
|
||||
```js
|
||||
Jimp.HORIZONTAL_ALIGN_CENTER | Jimp.VERTICAL_ALIGN_MIDDLE;
|
||||
```
|
61
app/node_modules/@jimp/plugin-cover/dist/index.js
generated
vendored
Normal file
61
app/node_modules/@jimp/plugin-cover/dist/index.js
generated
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
"use strict";
|
||||
|
||||
require("core-js/modules/es6.object.define-property");
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
var _utils = require("@jimp/utils");
|
||||
|
||||
/**
|
||||
* Scale the image so the given width and height keeping the aspect ratio. Some parts of the image may be clipped.
|
||||
* @param {number} w the width to resize the image to
|
||||
* @param {number} h the height to resize the image to
|
||||
* @param {number} alignBits (optional) A bitmask for horizontal and vertical alignment
|
||||
* @param {string} mode (optional) a scaling method (e.g. Jimp.RESIZE_BEZIER)
|
||||
* @param {function(Error, Jimp)} cb (optional) a callback for when complete
|
||||
* @returns {Jimp} this for chaining of methods
|
||||
*/
|
||||
var _default = function _default() {
|
||||
return {
|
||||
cover: function cover(w, h, alignBits, mode, cb) {
|
||||
if (typeof w !== 'number' || typeof h !== 'number') {
|
||||
return _utils.throwError.call(this, 'w and h must be numbers', cb);
|
||||
}
|
||||
|
||||
if (alignBits && typeof alignBits === 'function' && typeof cb === 'undefined') {
|
||||
cb = alignBits;
|
||||
alignBits = null;
|
||||
mode = null;
|
||||
} else if (typeof mode === 'function' && typeof cb === 'undefined') {
|
||||
cb = mode;
|
||||
mode = null;
|
||||
}
|
||||
|
||||
alignBits = alignBits || this.constructor.HORIZONTAL_ALIGN_CENTER | this.constructor.VERTICAL_ALIGN_MIDDLE;
|
||||
var hbits = alignBits & (1 << 3) - 1;
|
||||
var vbits = alignBits >> 3; // check if more flags than one is in the bit sets
|
||||
|
||||
if (!(hbits !== 0 && !(hbits & hbits - 1) || vbits !== 0 && !(vbits & vbits - 1))) return _utils.throwError.call(this, 'only use one flag per alignment direction', cb);
|
||||
var alignH = hbits >> 1; // 0, 1, 2
|
||||
|
||||
var alignV = vbits >> 1; // 0, 1, 2
|
||||
|
||||
var f = w / h > this.bitmap.width / this.bitmap.height ? w / this.bitmap.width : h / this.bitmap.height;
|
||||
this.scale(f, mode);
|
||||
this.crop((this.bitmap.width - w) / 2 * alignH, (this.bitmap.height - h) / 2 * alignV, w, h);
|
||||
|
||||
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/plugin-cover/dist/index.js.map
generated
vendored
Normal file
1
app/node_modules/@jimp/plugin-cover/dist/index.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../src/index.js"],"names":["cover","w","h","alignBits","mode","cb","throwError","call","constructor","HORIZONTAL_ALIGN_CENTER","VERTICAL_ALIGN_MIDDLE","hbits","vbits","alignH","alignV","f","bitmap","width","height","scale","crop"],"mappings":";;;;;;;;;AAAA;;AAEA;;;;;;;;;eASe;AAAA,SAAO;AACpBA,IAAAA,KADoB,iBACdC,CADc,EACXC,CADW,EACRC,SADQ,EACGC,IADH,EACSC,EADT,EACa;AAC/B,UAAI,OAAOJ,CAAP,KAAa,QAAb,IAAyB,OAAOC,CAAP,KAAa,QAA1C,EAAoD;AAClD,eAAOI,kBAAWC,IAAX,CAAgB,IAAhB,EAAsB,yBAAtB,EAAiDF,EAAjD,CAAP;AACD;;AAED,UACEF,SAAS,IACT,OAAOA,SAAP,KAAqB,UADrB,IAEA,OAAOE,EAAP,KAAc,WAHhB,EAIE;AACAA,QAAAA,EAAE,GAAGF,SAAL;AACAA,QAAAA,SAAS,GAAG,IAAZ;AACAC,QAAAA,IAAI,GAAG,IAAP;AACD,OARD,MAQO,IAAI,OAAOA,IAAP,KAAgB,UAAhB,IAA8B,OAAOC,EAAP,KAAc,WAAhD,EAA6D;AAClEA,QAAAA,EAAE,GAAGD,IAAL;AACAA,QAAAA,IAAI,GAAG,IAAP;AACD;;AAEDD,MAAAA,SAAS,GACPA,SAAS,IACT,KAAKK,WAAL,CAAiBC,uBAAjB,GACE,KAAKD,WAAL,CAAiBE,qBAHrB;AAIA,UAAMC,KAAK,GAAGR,SAAS,GAAI,CAAC,KAAK,CAAN,IAAW,CAAtC;AACA,UAAMS,KAAK,GAAGT,SAAS,IAAI,CAA3B,CAvB+B,CAyB/B;;AACA,UACE,EACGQ,KAAK,KAAK,CAAV,IAAe,EAAEA,KAAK,GAAIA,KAAK,GAAG,CAAnB,CAAhB,IACCC,KAAK,KAAK,CAAV,IAAe,EAAEA,KAAK,GAAIA,KAAK,GAAG,CAAnB,CAFlB,CADF,EAME,OAAON,kBAAWC,IAAX,CACL,IADK,EAEL,2CAFK,EAGLF,EAHK,CAAP;AAMF,UAAMQ,MAAM,GAAGF,KAAK,IAAI,CAAxB,CAtC+B,CAsCJ;;AAC3B,UAAMG,MAAM,GAAGF,KAAK,IAAI,CAAxB,CAvC+B,CAuCJ;;AAE3B,UAAMG,CAAC,GACLd,CAAC,GAAGC,CAAJ,GAAQ,KAAKc,MAAL,CAAYC,KAAZ,GAAoB,KAAKD,MAAL,CAAYE,MAAxC,GACIjB,CAAC,GAAG,KAAKe,MAAL,CAAYC,KADpB,GAEIf,CAAC,GAAG,KAAKc,MAAL,CAAYE,MAHtB;AAIA,WAAKC,KAAL,CAAWJ,CAAX,EAAcX,IAAd;AACA,WAAKgB,IAAL,CACG,CAAC,KAAKJ,MAAL,CAAYC,KAAZ,GAAoBhB,CAArB,IAA0B,CAA3B,GAAgCY,MADlC,EAEG,CAAC,KAAKG,MAAL,CAAYE,MAAZ,GAAqBhB,CAAtB,IAA2B,CAA5B,GAAiCY,MAFnC,EAGEb,CAHF,EAIEC,CAJF;;AAOA,UAAI,0BAAcG,EAAd,CAAJ,EAAuB;AACrBA,QAAAA,EAAE,CAACE,IAAH,CAAQ,IAAR,EAAc,IAAd,EAAoB,IAApB;AACD;;AAED,aAAO,IAAP;AACD;AA3DmB,GAAP;AAAA,C","sourcesContent":["import { isNodePattern, throwError } from '@jimp/utils';\n\n/**\n * Scale the image so the given width and height keeping the aspect ratio. Some parts of the image may be clipped.\n * @param {number} w the width to resize the image to\n * @param {number} h the height to resize the image to\n * @param {number} alignBits (optional) A bitmask for horizontal and vertical alignment\n * @param {string} mode (optional) a scaling method (e.g. Jimp.RESIZE_BEZIER)\n * @param {function(Error, Jimp)} cb (optional) a callback for when complete\n * @returns {Jimp} this for chaining of methods\n */\nexport default () => ({\n cover(w, h, alignBits, mode, cb) {\n if (typeof w !== 'number' || typeof h !== 'number') {\n return throwError.call(this, 'w and h must be numbers', cb);\n }\n\n if (\n alignBits &&\n typeof alignBits === 'function' &&\n typeof cb === 'undefined'\n ) {\n cb = alignBits;\n alignBits = null;\n mode = null;\n } else if (typeof mode === 'function' && typeof cb === 'undefined') {\n cb = mode;\n mode = null;\n }\n\n alignBits =\n alignBits ||\n this.constructor.HORIZONTAL_ALIGN_CENTER |\n this.constructor.VERTICAL_ALIGN_MIDDLE;\n const hbits = alignBits & ((1 << 3) - 1);\n const vbits = alignBits >> 3;\n\n // check if more flags than one is in the bit sets\n if (\n !(\n (hbits !== 0 && !(hbits & (hbits - 1))) ||\n (vbits !== 0 && !(vbits & (vbits - 1)))\n )\n )\n return throwError.call(\n this,\n 'only use one flag per alignment direction',\n cb\n );\n\n const alignH = hbits >> 1; // 0, 1, 2\n const alignV = vbits >> 1; // 0, 1, 2\n\n const f =\n w / h > this.bitmap.width / this.bitmap.height\n ? w / this.bitmap.width\n : h / this.bitmap.height;\n this.scale(f, mode);\n this.crop(\n ((this.bitmap.width - w) / 2) * alignH,\n ((this.bitmap.height - h) / 2) * alignV,\n w,\n h\n );\n\n if (isNodePattern(cb)) {\n cb.call(this, null, this);\n }\n\n return this;\n }\n});\n"],"file":"index.js"}
|
49
app/node_modules/@jimp/plugin-cover/es/index.js
generated
vendored
Normal file
49
app/node_modules/@jimp/plugin-cover/es/index.js
generated
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
import { isNodePattern, throwError } from '@jimp/utils';
|
||||
/**
|
||||
* Scale the image so the given width and height keeping the aspect ratio. Some parts of the image may be clipped.
|
||||
* @param {number} w the width to resize the image to
|
||||
* @param {number} h the height to resize the image to
|
||||
* @param {number} alignBits (optional) A bitmask for horizontal and vertical alignment
|
||||
* @param {string} mode (optional) a scaling method (e.g. Jimp.RESIZE_BEZIER)
|
||||
* @param {function(Error, Jimp)} cb (optional) a callback for when complete
|
||||
* @returns {Jimp} this for chaining of methods
|
||||
*/
|
||||
|
||||
export default (function () {
|
||||
return {
|
||||
cover: function cover(w, h, alignBits, mode, cb) {
|
||||
if (typeof w !== 'number' || typeof h !== 'number') {
|
||||
return throwError.call(this, 'w and h must be numbers', cb);
|
||||
}
|
||||
|
||||
if (alignBits && typeof alignBits === 'function' && typeof cb === 'undefined') {
|
||||
cb = alignBits;
|
||||
alignBits = null;
|
||||
mode = null;
|
||||
} else if (typeof mode === 'function' && typeof cb === 'undefined') {
|
||||
cb = mode;
|
||||
mode = null;
|
||||
}
|
||||
|
||||
alignBits = alignBits || this.constructor.HORIZONTAL_ALIGN_CENTER | this.constructor.VERTICAL_ALIGN_MIDDLE;
|
||||
var hbits = alignBits & (1 << 3) - 1;
|
||||
var vbits = alignBits >> 3; // check if more flags than one is in the bit sets
|
||||
|
||||
if (!(hbits !== 0 && !(hbits & hbits - 1) || vbits !== 0 && !(vbits & vbits - 1))) return throwError.call(this, 'only use one flag per alignment direction', cb);
|
||||
var alignH = hbits >> 1; // 0, 1, 2
|
||||
|
||||
var alignV = vbits >> 1; // 0, 1, 2
|
||||
|
||||
var f = w / h > this.bitmap.width / this.bitmap.height ? w / this.bitmap.width : h / this.bitmap.height;
|
||||
this.scale(f, mode);
|
||||
this.crop((this.bitmap.width - w) / 2 * alignH, (this.bitmap.height - h) / 2 * alignV, w, h);
|
||||
|
||||
if (isNodePattern(cb)) {
|
||||
cb.call(this, null, this);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
};
|
||||
});
|
||||
//# sourceMappingURL=index.js.map
|
1
app/node_modules/@jimp/plugin-cover/es/index.js.map
generated
vendored
Normal file
1
app/node_modules/@jimp/plugin-cover/es/index.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../src/index.js"],"names":["isNodePattern","throwError","cover","w","h","alignBits","mode","cb","call","constructor","HORIZONTAL_ALIGN_CENTER","VERTICAL_ALIGN_MIDDLE","hbits","vbits","alignH","alignV","f","bitmap","width","height","scale","crop"],"mappings":"AAAA,SAASA,aAAT,EAAwBC,UAAxB,QAA0C,aAA1C;AAEA;;;;;;;;;;AASA,gBAAe;AAAA,SAAO;AACpBC,IAAAA,KADoB,iBACdC,CADc,EACXC,CADW,EACRC,SADQ,EACGC,IADH,EACSC,EADT,EACa;AAC/B,UAAI,OAAOJ,CAAP,KAAa,QAAb,IAAyB,OAAOC,CAAP,KAAa,QAA1C,EAAoD;AAClD,eAAOH,UAAU,CAACO,IAAX,CAAgB,IAAhB,EAAsB,yBAAtB,EAAiDD,EAAjD,CAAP;AACD;;AAED,UACEF,SAAS,IACT,OAAOA,SAAP,KAAqB,UADrB,IAEA,OAAOE,EAAP,KAAc,WAHhB,EAIE;AACAA,QAAAA,EAAE,GAAGF,SAAL;AACAA,QAAAA,SAAS,GAAG,IAAZ;AACAC,QAAAA,IAAI,GAAG,IAAP;AACD,OARD,MAQO,IAAI,OAAOA,IAAP,KAAgB,UAAhB,IAA8B,OAAOC,EAAP,KAAc,WAAhD,EAA6D;AAClEA,QAAAA,EAAE,GAAGD,IAAL;AACAA,QAAAA,IAAI,GAAG,IAAP;AACD;;AAEDD,MAAAA,SAAS,GACPA,SAAS,IACT,KAAKI,WAAL,CAAiBC,uBAAjB,GACE,KAAKD,WAAL,CAAiBE,qBAHrB;AAIA,UAAMC,KAAK,GAAGP,SAAS,GAAI,CAAC,KAAK,CAAN,IAAW,CAAtC;AACA,UAAMQ,KAAK,GAAGR,SAAS,IAAI,CAA3B,CAvB+B,CAyB/B;;AACA,UACE,EACGO,KAAK,KAAK,CAAV,IAAe,EAAEA,KAAK,GAAIA,KAAK,GAAG,CAAnB,CAAhB,IACCC,KAAK,KAAK,CAAV,IAAe,EAAEA,KAAK,GAAIA,KAAK,GAAG,CAAnB,CAFlB,CADF,EAME,OAAOZ,UAAU,CAACO,IAAX,CACL,IADK,EAEL,2CAFK,EAGLD,EAHK,CAAP;AAMF,UAAMO,MAAM,GAAGF,KAAK,IAAI,CAAxB,CAtC+B,CAsCJ;;AAC3B,UAAMG,MAAM,GAAGF,KAAK,IAAI,CAAxB,CAvC+B,CAuCJ;;AAE3B,UAAMG,CAAC,GACLb,CAAC,GAAGC,CAAJ,GAAQ,KAAKa,MAAL,CAAYC,KAAZ,GAAoB,KAAKD,MAAL,CAAYE,MAAxC,GACIhB,CAAC,GAAG,KAAKc,MAAL,CAAYC,KADpB,GAEId,CAAC,GAAG,KAAKa,MAAL,CAAYE,MAHtB;AAIA,WAAKC,KAAL,CAAWJ,CAAX,EAAcV,IAAd;AACA,WAAKe,IAAL,CACG,CAAC,KAAKJ,MAAL,CAAYC,KAAZ,GAAoBf,CAArB,IAA0B,CAA3B,GAAgCW,MADlC,EAEG,CAAC,KAAKG,MAAL,CAAYE,MAAZ,GAAqBf,CAAtB,IAA2B,CAA5B,GAAiCW,MAFnC,EAGEZ,CAHF,EAIEC,CAJF;;AAOA,UAAIJ,aAAa,CAACO,EAAD,CAAjB,EAAuB;AACrBA,QAAAA,EAAE,CAACC,IAAH,CAAQ,IAAR,EAAc,IAAd,EAAoB,IAApB;AACD;;AAED,aAAO,IAAP;AACD;AA3DmB,GAAP;AAAA,CAAf","sourcesContent":["import { isNodePattern, throwError } from '@jimp/utils';\n\n/**\n * Scale the image so the given width and height keeping the aspect ratio. Some parts of the image may be clipped.\n * @param {number} w the width to resize the image to\n * @param {number} h the height to resize the image to\n * @param {number} alignBits (optional) A bitmask for horizontal and vertical alignment\n * @param {string} mode (optional) a scaling method (e.g. Jimp.RESIZE_BEZIER)\n * @param {function(Error, Jimp)} cb (optional) a callback for when complete\n * @returns {Jimp} this for chaining of methods\n */\nexport default () => ({\n cover(w, h, alignBits, mode, cb) {\n if (typeof w !== 'number' || typeof h !== 'number') {\n return throwError.call(this, 'w and h must be numbers', cb);\n }\n\n if (\n alignBits &&\n typeof alignBits === 'function' &&\n typeof cb === 'undefined'\n ) {\n cb = alignBits;\n alignBits = null;\n mode = null;\n } else if (typeof mode === 'function' && typeof cb === 'undefined') {\n cb = mode;\n mode = null;\n }\n\n alignBits =\n alignBits ||\n this.constructor.HORIZONTAL_ALIGN_CENTER |\n this.constructor.VERTICAL_ALIGN_MIDDLE;\n const hbits = alignBits & ((1 << 3) - 1);\n const vbits = alignBits >> 3;\n\n // check if more flags than one is in the bit sets\n if (\n !(\n (hbits !== 0 && !(hbits & (hbits - 1))) ||\n (vbits !== 0 && !(vbits & (vbits - 1)))\n )\n )\n return throwError.call(\n this,\n 'only use one flag per alignment direction',\n cb\n );\n\n const alignH = hbits >> 1; // 0, 1, 2\n const alignV = vbits >> 1; // 0, 1, 2\n\n const f =\n w / h > this.bitmap.width / this.bitmap.height\n ? w / this.bitmap.width\n : h / this.bitmap.height;\n this.scale(f, mode);\n this.crop(\n ((this.bitmap.width - w) / 2) * alignH,\n ((this.bitmap.height - h) / 2) * alignV,\n w,\n h\n );\n\n if (isNodePattern(cb)) {\n cb.call(this, null, this);\n }\n\n return this;\n }\n});\n"],"file":"index.js"}
|
71
app/node_modules/@jimp/plugin-cover/package.json
generated
vendored
Normal file
71
app/node_modules/@jimp/plugin-cover/package.json
generated
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"@jimp/plugin-cover@0.6.4",
|
||||
"C:\\Users\\ryuki\\TheDesk\\app"
|
||||
]
|
||||
],
|
||||
"_from": "@jimp/plugin-cover@0.6.4",
|
||||
"_id": "@jimp/plugin-cover@0.6.4",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-z6eafPonj3LJY8cTEfRkXmOfCDi1+f0tbYaNvmiu+OrWJ3Ojw2hMt+BVVvJ8pKe1dWIFkCjxOjyjZWj1gEkaLw==",
|
||||
"_location": "/@jimp/plugin-cover",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "@jimp/plugin-cover@0.6.4",
|
||||
"name": "@jimp/plugin-cover",
|
||||
"escapedName": "@jimp%2fplugin-cover",
|
||||
"scope": "@jimp",
|
||||
"rawSpec": "0.6.4",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "0.6.4"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/@jimp/plugins"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/@jimp/plugin-cover/-/plugin-cover-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"
|
||||
},
|
||||
"description": "cover an image.",
|
||||
"devDependencies": {
|
||||
"@jimp/custom": "^0.6.4",
|
||||
"@jimp/plugin-crop": "^0.6.4",
|
||||
"@jimp/plugin-resize": "^0.6.4",
|
||||
"@jimp/plugin-scale": "^0.6.4",
|
||||
"@jimp/test-utils": "^0.6.4"
|
||||
},
|
||||
"gitHead": "7c9d3c817cade88d4a20422be10670d3c1528429",
|
||||
"license": "MIT",
|
||||
"main": "dist/index.js",
|
||||
"module": "es/index.js",
|
||||
"name": "@jimp/plugin-cover",
|
||||
"peerDependencies": {
|
||||
"@jimp/custom": ">=0.3.5",
|
||||
"@jimp/plugin-crop": ">=0.3.5",
|
||||
"@jimp/plugin-resize": ">=0.3.5",
|
||||
"@jimp/plugin-scale": ">=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"
|
||||
}
|
72
app/node_modules/@jimp/plugin-cover/src/index.js
generated
vendored
Normal file
72
app/node_modules/@jimp/plugin-cover/src/index.js
generated
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
import { isNodePattern, throwError } from '@jimp/utils';
|
||||
|
||||
/**
|
||||
* Scale the image so the given width and height keeping the aspect ratio. Some parts of the image may be clipped.
|
||||
* @param {number} w the width to resize the image to
|
||||
* @param {number} h the height to resize the image to
|
||||
* @param {number} alignBits (optional) A bitmask for horizontal and vertical alignment
|
||||
* @param {string} mode (optional) a scaling method (e.g. Jimp.RESIZE_BEZIER)
|
||||
* @param {function(Error, Jimp)} cb (optional) a callback for when complete
|
||||
* @returns {Jimp} this for chaining of methods
|
||||
*/
|
||||
export default () => ({
|
||||
cover(w, h, alignBits, mode, cb) {
|
||||
if (typeof w !== 'number' || typeof h !== 'number') {
|
||||
return throwError.call(this, 'w and h must be numbers', cb);
|
||||
}
|
||||
|
||||
if (
|
||||
alignBits &&
|
||||
typeof alignBits === 'function' &&
|
||||
typeof cb === 'undefined'
|
||||
) {
|
||||
cb = alignBits;
|
||||
alignBits = null;
|
||||
mode = null;
|
||||
} else if (typeof mode === 'function' && typeof cb === 'undefined') {
|
||||
cb = mode;
|
||||
mode = null;
|
||||
}
|
||||
|
||||
alignBits =
|
||||
alignBits ||
|
||||
this.constructor.HORIZONTAL_ALIGN_CENTER |
|
||||
this.constructor.VERTICAL_ALIGN_MIDDLE;
|
||||
const hbits = alignBits & ((1 << 3) - 1);
|
||||
const vbits = alignBits >> 3;
|
||||
|
||||
// check if more flags than one is in the bit sets
|
||||
if (
|
||||
!(
|
||||
(hbits !== 0 && !(hbits & (hbits - 1))) ||
|
||||
(vbits !== 0 && !(vbits & (vbits - 1)))
|
||||
)
|
||||
)
|
||||
return throwError.call(
|
||||
this,
|
||||
'only use one flag per alignment direction',
|
||||
cb
|
||||
);
|
||||
|
||||
const alignH = hbits >> 1; // 0, 1, 2
|
||||
const alignV = vbits >> 1; // 0, 1, 2
|
||||
|
||||
const f =
|
||||
w / h > this.bitmap.width / this.bitmap.height
|
||||
? w / this.bitmap.width
|
||||
: h / this.bitmap.height;
|
||||
this.scale(f, mode);
|
||||
this.crop(
|
||||
((this.bitmap.width - w) / 2) * alignH,
|
||||
((this.bitmap.height - h) / 2) * alignV,
|
||||
w,
|
||||
h
|
||||
);
|
||||
|
||||
if (isNodePattern(cb)) {
|
||||
cb.call(this, null, this);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
});
|
131
app/node_modules/@jimp/plugin-cover/test/cover.test.js
generated
vendored
Normal file
131
app/node_modules/@jimp/plugin-cover/test/cover.test.js
generated
vendored
Normal file
@@ -0,0 +1,131 @@
|
||||
import { Jimp, mkJGD, hasOwnProp } from '@jimp/test-utils';
|
||||
import configure from '@jimp/custom';
|
||||
import crop from '@jimp/plugin-crop';
|
||||
import scale from '@jimp/plugin-scale';
|
||||
import resize from '@jimp/plugin-resize';
|
||||
|
||||
import cover from '../src';
|
||||
|
||||
const jimp = configure({ plugins: [resize, scale, crop, cover] }, Jimp);
|
||||
|
||||
describe('All align combinations for cover', () => {
|
||||
const verticalJGD = mkJGD(
|
||||
'▴▴▴▴▸▸▸▸',
|
||||
'▴▴▴▴▸▸▸▸',
|
||||
'▴▴▴▴▸▸▸▸',
|
||||
'▴▴▴▴▸▸▸▸',
|
||||
'▴▴▴▴▸▸▸▸',
|
||||
'▴▴▴▴▸▸▸▸',
|
||||
'▾▾▾▾◆◆◆◆',
|
||||
'▾▾▾▾◆◆◆◆',
|
||||
'▾▾▾▾◆◆◆◆',
|
||||
'▾▾▾▾◆◆◆◆',
|
||||
'▾▾▾▾◆◆◆◆',
|
||||
'▾▾▾▾◆◆◆◆'
|
||||
);
|
||||
|
||||
const horizontalJGD = mkJGD(
|
||||
'▴▴▴▴▴▴▸▸▸▸▸▸',
|
||||
'▴▴▴▴▴▴▸▸▸▸▸▸',
|
||||
'▴▴▴▴▴▴▸▸▸▸▸▸',
|
||||
'▴▴▴▴▴▴▸▸▸▸▸▸',
|
||||
'▾▾▾▾▾▾◆◆◆◆◆◆',
|
||||
'▾▾▾▾▾▾◆◆◆◆◆◆',
|
||||
'▾▾▾▾▾▾◆◆◆◆◆◆',
|
||||
'▾▾▾▾▾▾◆◆◆◆◆◆'
|
||||
);
|
||||
|
||||
let vertical;
|
||||
let horizontal; // stores the Jimp instances of the JGD images above.
|
||||
|
||||
before(done => {
|
||||
const img1 = jimp.read(verticalJGD);
|
||||
const img2 = jimp.read(horizontalJGD);
|
||||
Promise.all([img1, img2])
|
||||
.then(images => {
|
||||
vertical = images[0];
|
||||
horizontal = images[1];
|
||||
done();
|
||||
})
|
||||
.catch(done);
|
||||
});
|
||||
|
||||
const tests = {}; // Stores the expected result for each alignment combination.
|
||||
tests['LEFT TOP'] = {
|
||||
cover: {
|
||||
verti: mkJGD('▴▴▸▸', '▴▴▸▸', '▴▴▸▸', '▾▾◆◆'),
|
||||
horiz: mkJGD('▴▴▴▸', '▴▴▴▸', '▾▾▾◆', '▾▾▾◆')
|
||||
}
|
||||
};
|
||||
tests['CENTER TOP'] = {
|
||||
cover: {
|
||||
verti: mkJGD('▴▴▸▸', '▴▴▸▸', '▴▴▸▸', '▾▾◆◆'),
|
||||
horiz: mkJGD('▴▴▸▸', '▴▴▸▸', '▾▾◆◆', '▾▾◆◆')
|
||||
}
|
||||
};
|
||||
tests['RIGHT TOP'] = {
|
||||
cover: {
|
||||
verti: mkJGD('▴▴▸▸', '▴▴▸▸', '▴▴▸▸', '▾▾◆◆'),
|
||||
horiz: mkJGD('▴▸▸▸', '▴▸▸▸', '▾◆◆◆', '▾◆◆◆')
|
||||
}
|
||||
};
|
||||
|
||||
tests['LEFT MIDDLE'] = {
|
||||
cover: {
|
||||
verti: mkJGD('▴▴▸▸', '▴▴▸▸', '▾▾◆◆', '▾▾◆◆'),
|
||||
horiz: mkJGD('▴▴▴▸', '▴▴▴▸', '▾▾▾◆', '▾▾▾◆')
|
||||
}
|
||||
};
|
||||
tests['CENTER MIDDLE'] = {
|
||||
cover: {
|
||||
verti: mkJGD('▴▴▸▸', '▴▴▸▸', '▾▾◆◆', '▾▾◆◆'),
|
||||
horiz: mkJGD('▴▴▸▸', '▴▴▸▸', '▾▾◆◆', '▾▾◆◆')
|
||||
}
|
||||
};
|
||||
tests['RIGHT MIDDLE'] = {
|
||||
cover: {
|
||||
verti: mkJGD('▴▴▸▸', '▴▴▸▸', '▾▾◆◆', '▾▾◆◆'),
|
||||
horiz: mkJGD('▴▸▸▸', '▴▸▸▸', '▾◆◆◆', '▾◆◆◆')
|
||||
}
|
||||
};
|
||||
|
||||
tests['LEFT BOTTOM'] = {
|
||||
cover: {
|
||||
verti: mkJGD('▴▴▸▸', '▾▾◆◆', '▾▾◆◆', '▾▾◆◆'),
|
||||
horiz: mkJGD('▴▴▴▸', '▴▴▴▸', '▾▾▾◆', '▾▾▾◆')
|
||||
}
|
||||
};
|
||||
tests['CENTER BOTTOM'] = {
|
||||
cover: {
|
||||
verti: mkJGD('▴▴▸▸', '▾▾◆◆', '▾▾◆◆', '▾▾◆◆'),
|
||||
horiz: mkJGD('▴▴▸▸', '▴▴▸▸', '▾▾◆◆', '▾▾◆◆')
|
||||
}
|
||||
};
|
||||
tests['RIGHT BOTTOM'] = {
|
||||
cover: {
|
||||
verti: mkJGD('▴▴▸▸', '▾▾◆◆', '▾▾◆◆', '▾▾◆◆'),
|
||||
horiz: mkJGD('▴▸▸▸', '▴▸▸▸', '▾◆◆◆', '▾◆◆◆')
|
||||
}
|
||||
};
|
||||
|
||||
function runAlignTest(align) {
|
||||
const jgdCoverV = tests[align].cover.verti;
|
||||
const jgdCoverH = tests[align].cover.horiz;
|
||||
let a = align.split(' ');
|
||||
a = Jimp['HORIZONTAL_ALIGN_' + a[0]] | Jimp['VERTICAL_ALIGN_' + a[1]];
|
||||
it('cover aligned to ' + align, () => {
|
||||
vertical
|
||||
.clone()
|
||||
.cover(4, 4, a)
|
||||
.getJGDSync()
|
||||
.should.be.sameJGD(jgdCoverV, 'Vertical image');
|
||||
horizontal
|
||||
.clone()
|
||||
.cover(4, 4, a)
|
||||
.getJGDSync()
|
||||
.should.be.sameJGD(jgdCoverH, 'Horizontal image');
|
||||
});
|
||||
}
|
||||
|
||||
for (const align in tests) if (hasOwnProp(tests, align)) runAlignTest(align);
|
||||
});
|
Reference in New Issue
Block a user