Socket
Socket
Sign inDemoInstall

@jimp/plugin-resize

Package Overview
Dependencies
Maintainers
0
Versions
240
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jimp/plugin-resize - npm Package Compare versions

Comparing version 1.0.5 to 1.1.0

1

.tshy/build.json

@@ -5,3 +5,2 @@ {

"rootDir": "../src",
"target": "es2022",
"module": "nodenext",

@@ -8,0 +7,0 @@ "moduleResolution": "nodenext"

6

.tshy/commonjs.json

@@ -6,7 +6,9 @@ {

"../src/**/*.cts",
"../src/**/*.tsx"
"../src/**/*.tsx",
"../src/**/*.json"
],
"exclude": [
"../**/*.test.ts",
"../src/**/*.mts"
"../src/**/*.mts",
"../src/package.json"
],

@@ -13,0 +15,0 @@ "compilerOptions": {

@@ -6,6 +6,8 @@ {

"../src/**/*.mts",
"../src/**/*.tsx"
"../src/**/*.tsx",
"../src/**/*.json"
],
"exclude": [
"../**/*.test.ts"
"../**/*.test.ts",
"../src/package.json"
],

@@ -12,0 +14,0 @@ "compilerOptions": {

@@ -0,1 +1,14 @@

# v1.1.0 (Sun Sep 01 2024)
#### ⚠️ Pushed to `main`
- upgrade tshy ([@hipstersmoothie](https://github.com/hipstersmoothie))
- update more docs ([@hipstersmoothie](https://github.com/hipstersmoothie))
#### Authors: 1
- Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie))
---
# v1.0.3 (Sat Aug 31 2024)

@@ -2,0 +15,0 @@

{
"name": "@jimp/plugin-resize",
"version": "1.0.5",
"version": "1.1.0",
"repository": "jimp-dev/jimp",

@@ -16,15 +16,15 @@ "scripts": {

"dependencies": {
"@jimp/core": "1.0.5",
"@jimp/types": "1.0.5",
"@jimp/core": "1.1.0",
"@jimp/types": "1.1.0",
"zod": "^3.22.4"
},
"devDependencies": {
"@jimp/config-eslint": "1.0.5",
"@jimp/config-typescript": "1.0.5",
"@jimp/config-vitest": "1.0.5",
"@jimp/test-utils": "1.0.5",
"@jimp/config-eslint": "1.1.0",
"@jimp/config-typescript": "1.1.0",
"@jimp/config-vitest": "1.1.0",
"@jimp/test-utils": "1.1.0",
"@types/node": "^20.12.5",
"@vitest/browser": "^1.4.0",
"eslint": "^8.57.0",
"tshy": "^1.12.0",
"tshy": "^3.0.2",
"typescript": "^5.5.4",

@@ -63,3 +63,4 @@ "vite-plugin-node-polyfills": "^0.21.0",

"sideEffects": false,
"gitHead": "44ab95c1875f9f94d993d7a48d66de00115fb4a8"
"module": "./dist/esm/index.js",
"gitHead": "887b0cb53fe5b8d545c8cda82a3db5ef90f18136"
}

@@ -10,94 +10,4 @@ <div align="center">

## Usage
- @param {number} w the width to resize the image to (or ResizeStrategy.AUTO)
- @param {number} h the height to resize the image to (or ResizeStrategy.AUTO)
- @param {string} mode (optional) a scaling method (e.g. ResizeStrategy.BEZIER)
```js
import jimp, { ResizeStrategy } from "jimp";
async function main() {
// Read the image.
const image = await jimp.read("test/image.png");
// Resize the image to width 150 and auto height.
await image.resize(150, ResizeStrategy.AUTO);
// Save and overwrite the image
await image.writeAsync("test/image.png");
}
main();
```
## Auto
`ResizeStrategy.AUTO` can be passes to either the height or width and jimp will scale the image accordingly. `ResizeStrategy.AUTO` cannot be both height and width.
```js
// resize the height to 250 and scale the width accordingly
image.resize(ResizeStrategy.AUTO, 250);
// resize the width to 250 and scale the height accordingly
image.resize(250, ResizeStrategy.AUTO);
```
### Resize modes
The default resizing algorithm uses a bilinear method.
Optionally, the following constants can be passed to choose a particular resizing algorithm:
```js
ResizeStrategy.NEAREST_NEIGHBOR;
ResizeStrategy.BILINEAR;
ResizeStrategy.BICUBIC;
ResizeStrategy.HERMITE;
ResizeStrategy.BEZIER;
```
```js
image.resize(250, 250, ResizeStrategy.BEZIER);
```
## 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();
```
- [resize](http://jimp-dev.github.io/jimp/api/jimp/classes/jimp#resize)
- [scale](http://jimp-dev.github.io/jimp/api/jimp/classes/jimp#scale)
- [scaleToFit](http://jimp-dev.github.io/jimp/api/jimp/classes/jimp#scaletofit)

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc