初始化

This commit is contained in:
yziiy
2025-08-11 11:06:07 +08:00
parent 083bc37c00
commit 5607d11395
19772 changed files with 3108723 additions and 18 deletions

View File

@@ -0,0 +1,11 @@
# v0.9.3 (Tue Nov 26 2019)
#### 🐛 Bug Fix
- `@jimp/cli`, `@jimp/core`, `@jimp/custom`, `jimp`, `@jimp/plugin-blit`, `@jimp/plugin-blur`, `@jimp/plugin-circle`, `@jimp/plugin-color`, `@jimp/plugin-contain`, `@jimp/plugin-cover`, `@jimp/plugin-crop`, `@jimp/plugin-displace`, `@jimp/plugin-dither`, `@jimp/plugin-fisheye`, `@jimp/plugin-flip`, `@jimp/plugin-gaussian`, `@jimp/plugin-invert`, `@jimp/plugin-mask`, `@jimp/plugin-normalize`, `@jimp/plugin-print`, `@jimp/plugin-resize`, `@jimp/plugin-rotate`, `@jimp/plugin-scale`, `@jimp/plugin-shadow`, `@jimp/plugin-threshold`, `@jimp/plugins`, `@jimp/test-utils`, `@jimp/bmp`, `@jimp/gif`, `@jimp/jpeg`, `@jimp/png`, `@jimp/tiff`, `@jimp/types`, `@jimp/utils`
- Fix regeneratorRuntime errors [#815](https://github.com/oliver-moran/jimp/pull/815) ([@crutchcorn](https://github.com/crutchcorn) [@hipstersmoothie](https://github.com/hipstersmoothie))
#### Authors: 2
- Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie))
- Corbin Crutchley ([@crutchcorn](https://github.com/crutchcorn))

View 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.

View File

@@ -0,0 +1,48 @@
<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-scale</h1>
<p>Scale an image.</p>
</div>
## scale
Uniformly scales the image by a factor.
- @param {number} f the factor to scale the image by
- @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.scale(2);
image.scale(2, jimp.RESIZE_BEZIER);
}
main();
```
## scaleToFit
Scale the image to the largest size that fits inside the rectangle that has the given width and height.
- @param {number} w the width to resize the image to
- @param {number} h the height to resize the image to
- @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.scaleToFit(100, 100);
}
main();
```

View File

@@ -0,0 +1,76 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _utils = require("@jimp/utils");
var _default = function _default() {
return {
/**
* Uniformly scales the image by a factor.
* @param {number} f the factor to scale the image by
* @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
*/
scale: function scale(f, mode, cb) {
if (typeof f !== 'number') {
return _utils.throwError.call(this, 'f must be a number', cb);
}
if (f < 0) {
return _utils.throwError.call(this, 'f must be a positive number', cb);
}
if (typeof mode === 'function' && typeof cb === 'undefined') {
cb = mode;
mode = null;
}
var w = this.bitmap.width * f;
var h = this.bitmap.height * f;
this.resize(w, h, mode);
if ((0, _utils.isNodePattern)(cb)) {
cb.call(this, null, this);
}
return this;
},
/**
* Scale the image to the largest size that fits inside the rectangle that has the given width and height.
* @param {number} w the width to resize the image to
* @param {number} h the height to resize the image to
* @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
*/
scaleToFit: function scaleToFit(w, h, mode, cb) {
if (typeof w !== 'number' || typeof h !== 'number') {
return _utils.throwError.call(this, 'w and h must be numbers', cb);
}
if (typeof mode === 'function' && typeof cb === 'undefined') {
cb = mode;
mode = null;
}
var f = w / h > this.bitmap.width / this.bitmap.height ? h / this.bitmap.height : w / this.bitmap.width;
this.scale(f, mode);
if ((0, _utils.isNodePattern)(cb)) {
cb.call(this, null, this);
}
return this;
}
};
};
exports["default"] = _default;
module.exports = exports.default;
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../src/index.js"],"names":["scale","f","mode","cb","throwError","call","w","bitmap","width","h","height","resize","scaleToFit"],"mappings":";;;;;;;AAAA;;eAEe;AAAA,SAAO;AACpB;;;;;;;AAOAA,IAAAA,KARoB,iBAQdC,CARc,EAQXC,IARW,EAQLC,EARK,EAQD;AACjB,UAAI,OAAOF,CAAP,KAAa,QAAjB,EAA2B;AACzB,eAAOG,kBAAWC,IAAX,CAAgB,IAAhB,EAAsB,oBAAtB,EAA4CF,EAA5C,CAAP;AACD;;AAED,UAAIF,CAAC,GAAG,CAAR,EAAW;AACT,eAAOG,kBAAWC,IAAX,CAAgB,IAAhB,EAAsB,6BAAtB,EAAqDF,EAArD,CAAP;AACD;;AAED,UAAI,OAAOD,IAAP,KAAgB,UAAhB,IAA8B,OAAOC,EAAP,KAAc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AAED,aAAO,IAAP;AACD;AA9DmB,GAAP;AAAA,C","sourcesContent":["import { isNodePattern, throwError } from '@jimp/utils';\n\nexport default () => ({\n /**\n * Uniformly scales the image by a factor.\n * @param {number} f the factor to scale the image by\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 */\n scale(f, mode, cb) {\n if (typeof f !== 'number') {\n return throwError.call(this, 'f must be a number', cb);\n }\n\n if (f < 0) {\n return throwError.call(this, 'f must be a positive number', cb);\n }\n\n if (typeof mode === 'function' && typeof cb === 'undefined') {\n cb = mode;\n mode = null;\n }\n\n const w = this.bitmap.width * f;\n const h = this.bitmap.height * f;\n this.resize(w, h, mode);\n\n if (isNodePattern(cb)) {\n cb.call(this, null, this);\n }\n\n return this;\n },\n\n /**\n * Scale the image to the largest size that fits inside the rectangle that has the given width and height.\n * @param {number} w the width to resize the image to\n * @param {number} h the height to resize the image to\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 */\n scaleToFit(w, h, 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 (typeof mode === 'function' && typeof cb === 'undefined') {\n cb = mode;\n mode = null;\n }\n\n const f =\n w / h > this.bitmap.width / this.bitmap.height\n ? h / this.bitmap.height\n : w / this.bitmap.width;\n this.scale(f, mode);\n\n if (isNodePattern(cb)) {\n cb.call(this, null, this);\n }\n\n return this;\n }\n});\n"],"file":"index.js"}

View File

@@ -0,0 +1,75 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _utils = require("@jimp/utils");
var _default = function _default() {
return {
/**
* Uniformly scales the image by a factor.
* @param {number} f the factor to scale the image by
* @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
*/
scale: function scale(f, mode, cb) {
if (typeof f !== 'number') {
return _utils.throwError.call(this, 'f must be a number', cb);
}
if (f < 0) {
return _utils.throwError.call(this, 'f must be a positive number', cb);
}
if (typeof mode === 'function' && typeof cb === 'undefined') {
cb = mode;
mode = null;
}
var w = this.bitmap.width * f;
var h = this.bitmap.height * f;
this.resize(w, h, mode);
if ((0, _utils.isNodePattern)(cb)) {
cb.call(this, null, this);
}
return this;
},
/**
* Scale the image to the largest size that fits inside the rectangle that has the given width and height.
* @param {number} w the width to resize the image to
* @param {number} h the height to resize the image to
* @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
*/
scaleToFit: function scaleToFit(w, h, mode, cb) {
if (typeof w !== 'number' || typeof h !== 'number') {
return _utils.throwError.call(this, 'w and h must be numbers', cb);
}
if (typeof mode === 'function' && typeof cb === 'undefined') {
cb = mode;
mode = null;
}
var f = w / h > this.bitmap.width / this.bitmap.height ? h / this.bitmap.height : w / this.bitmap.width;
this.scale(f, mode);
if ((0, _utils.isNodePattern)(cb)) {
cb.call(this, null, this);
}
return this;
}
};
};
exports["default"] = _default;
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../src/index.js"],"names":["scale","f","mode","cb","throwError","call","w","bitmap","width","h","height","resize","scaleToFit"],"mappings":";;;;;;;AAAA;;eAEe;AAAA,SAAO;AACpB;;;;;;;AAOAA,IAAAA,KARoB,iBAQdC,CARc,EAQXC,IARW,EAQLC,EARK,EAQD;AACjB,UAAI,OAAOF,CAAP,KAAa,QAAjB,EAA2B;AACzB,eAAOG,kBAAWC,IAAX,CAAgB,IAAhB,EAAsB,oBAAtB,EAA4CF,EAA5C,CAAP;AACD;;AAED,UAAIF,CAAC,GAAG,CAAR,EAAW;AACT,eAAOG,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X,EAAcC,IAAd;;AAEA,UAAI,0BAAcC,EAAd,CAAJ,EAAuB;AACrBA,QAAAA,EAAE,CAACE,IAAH,CAAQ,IAAR,EAAc,IAAd,EAAoB,IAApB;AACD;;AAED,aAAO,IAAP;AACD;AA9DmB,GAAP;AAAA,C","sourcesContent":["import { isNodePattern, throwError } from '@jimp/utils';\n\nexport default () => ({\n /**\n * Uniformly scales the image by a factor.\n * @param {number} f the factor to scale the image by\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 */\n scale(f, mode, cb) {\n if (typeof f !== 'number') {\n return throwError.call(this, 'f must be a number', cb);\n }\n\n if (f < 0) {\n return throwError.call(this, 'f must be a positive number', cb);\n }\n\n if (typeof mode === 'function' && typeof cb === 'undefined') {\n cb = mode;\n mode = null;\n }\n\n const w = this.bitmap.width * f;\n const h = this.bitmap.height * f;\n this.resize(w, h, mode);\n\n if (isNodePattern(cb)) {\n cb.call(this, null, this);\n }\n\n return this;\n },\n\n /**\n * Scale the image to the largest size that fits inside the rectangle that has the given width and height.\n * @param {number} w the width to resize the image to\n * @param {number} h the height to resize the image to\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 */\n scaleToFit(w, h, 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 (typeof mode === 'function' && typeof cb === 'undefined') {\n cb = mode;\n mode = null;\n }\n\n const f =\n w / h > this.bitmap.width / this.bitmap.height\n ? h / this.bitmap.height\n : w / this.bitmap.width;\n this.scale(f, mode);\n\n if (isNodePattern(cb)) {\n cb.call(this, null, this);\n }\n\n return this;\n }\n});\n"],"file":"index.js"}

View File

@@ -0,0 +1,10 @@
import { ImageCallback } from '@jimp/core';
interface Scale {
scale(f: number, cb?: ImageCallback<this>): this;
scale(f: number, mode?: string, cb?: ImageCallback<this>): this;
scaleToFit(w: number, h: number, cb?: ImageCallback<this>): this;
scaleToFit(w: number, h: number, mode?: string, cb?: ImageCallback<this>): this;
}
export default function(): Scale;

View File

@@ -0,0 +1,32 @@
{
"name": "@jimp/plugin-scale",
"version": "0.10.3",
"description": "scale an image.",
"main": "dist/index.js",
"module": "es/index.js",
"types": "index.d.ts",
"scripts": {
"build": "npm run build:node:production && npm run build:module",
"build:watch": "npm run build:node:debug -- -- --watch --verbose",
"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"
},
"author": "",
"license": "MIT",
"dependencies": {
"@babel/runtime": "^7.7.2",
"@jimp/utils": "^0.10.3",
"core-js": "^3.4.1"
},
"peerDependencies": {
"@jimp/custom": ">=0.3.5",
"@jimp/plugin-resize": ">=0.3.5"
},
"publishConfig": {
"access": "public"
},
"gitHead": "37197106eae5c26231018dfdc0254422f6b43927"
}

View File

@@ -0,0 +1,66 @@
import { isNodePattern, throwError } from '@jimp/utils';
export default () => ({
/**
* Uniformly scales the image by a factor.
* @param {number} f the factor to scale the image by
* @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
*/
scale(f, mode, cb) {
if (typeof f !== 'number') {
return throwError.call(this, 'f must be a number', cb);
}
if (f < 0) {
return throwError.call(this, 'f must be a positive number', cb);
}
if (typeof mode === 'function' && typeof cb === 'undefined') {
cb = mode;
mode = null;
}
const w = this.bitmap.width * f;
const h = this.bitmap.height * f;
this.resize(w, h, mode);
if (isNodePattern(cb)) {
cb.call(this, null, this);
}
return this;
},
/**
* Scale the image to the largest size that fits inside the rectangle that has the given width and height.
* @param {number} w the width to resize the image to
* @param {number} h the height to resize the image to
* @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
*/
scaleToFit(w, h, mode, cb) {
if (typeof w !== 'number' || typeof h !== 'number') {
return throwError.call(this, 'w and h must be numbers', cb);
}
if (typeof mode === 'function' && typeof cb === 'undefined') {
cb = mode;
mode = null;
}
const f =
w / h > this.bitmap.width / this.bitmap.height
? h / this.bitmap.height
: w / this.bitmap.width;
this.scale(f, mode);
if (isNodePattern(cb)) {
cb.call(this, null, this);
}
return this;
}
});