Socket
Socket
Sign inDemoInstall

ipx

Package Overview
Dependencies
Maintainers
2
Versions
70
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ipx - npm Package Compare versions

Comparing version 0.7.1 to 0.7.2

CHANGELOG.md

37

dist/cli.js

@@ -40,2 +40,3 @@ #!/usr/bin/env node

get background () { return background; },
get enlarge () { return enlarge; },
get width () { return width; },

@@ -177,2 +178,15 @@ get height () { return height; },

}
function clampDimensionsPreservingAspectRatio(sourceDimensions, desiredDimensions) {
const desiredAspectRatio = desiredDimensions.width / desiredDimensions.height;
let { width, height } = desiredDimensions;
if (width > sourceDimensions.width) {
width = sourceDimensions.width;
height = Math.round(sourceDimensions.width / desiredAspectRatio);
}
if (height > sourceDimensions.height) {
height = sourceDimensions.height;
width = Math.round(sourceDimensions.height * desiredAspectRatio);
}
return { width, height };
}

@@ -206,6 +220,12 @@ const quality = {

};
const enlarge = {
args: [],
apply: (context) => {
context.enlarge = true;
}
};
const width = {
args: [VArg],
apply: (_context, pipe, width2) => {
return pipe.resize(width2, null);
apply: (context, pipe, width2) => {
return pipe.resize(width2, null, { withoutEnlargement: !context.enlarge });
}

@@ -215,4 +235,4 @@ };

args: [VArg],
apply: (_context, pipe, height2) => {
return pipe.resize(null, height2);
apply: (context, pipe, height2) => {
return pipe.resize(null, height2, { withoutEnlargement: !context.enlarge });
}

@@ -223,3 +243,8 @@ };

apply: (context, pipe, size) => {
const [width2, height2] = String(size).split("x").map((v) => Number(v));
let [width2, height2] = String(size).split("x").map((v) => Number(v));
if (!context.enlarge) {
const clamped = clampDimensionsPreservingAspectRatio(context.meta, { width: width2, height: height2 });
width2 = clamped.width;
height2 = clamped.height;
}
return pipe.resize(width2, height2, {

@@ -427,3 +452,3 @@ fit: context.fit,

});
const handlerCtx = {};
const handlerCtx = { meta };
for (const h of handlers) {

@@ -430,0 +455,0 @@ sharp = applyHandler(handlerCtx, sharp, h.handler, h.args) || sharp;

2

package.json
{
"name": "ipx",
"version": "0.7.1",
"version": "0.7.2",
"repository": "unjs/ipx",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -55,21 +55,23 @@ # IPX

| Property | Docs | Example | Comments |
| --------- | :-------------------------------------------------------------- | :----------------------------------------------- | :-------------------------------------------------------------------- |
| width | \_ | `http://localhost:3000/width_200/buffalo.png` |
| height | \_ | `http://localhost:3000/height_200/buffalo.png` |
| trim | [Docs](https://sharp.pixelplumbing.com/api-resize#trim) | `http://localhost:3000/trim_100/buffalo.png` |
| format | [Docs](https://sharp.pixelplumbing.com/api-output#toformat) | `http://localhost:3000/format_webp/buffalo.png` | Supported format: `jpg`, `jpeg`, `png`, `webp`, `avif`, `gif`, `heif` |
| quality | \_ | `http://localhost:3000/quality_50/buffalo.png` | Accepted values: 0 to 100 |
| rotate | [Docs](https://sharp.pixelplumbing.com/api-operation#rotate) | `http://localhost:3000/rotate_45/buffalo.png` |
| flip | [Docs](https://sharp.pixelplumbing.com/api-operation#flip) | `http://localhost:3000/flip/buffalo.png` |
| flop | [Docs](https://sharp.pixelplumbing.com/api-operation#flop) | `http://localhost:3000/flop/buffalo.png` |
| sharpen | [Docs](https://sharp.pixelplumbing.com/api-operation#sharpen) | `http://localhost:3000/sharpen_30/buffalo.png` |
| median | [Docs](https://sharp.pixelplumbing.com/api-operation#median) | `http://localhost:3000/median_10/buffalo.png` |
| gamma | [Docs](https://sharp.pixelplumbing.com/api-operation#gamma) | `http://localhost:3000/gamma_3/buffalo.png` |
| negate | [Docs](https://sharp.pixelplumbing.com/api-operation#negate) | `http://localhost:3000/negate/buffalo.png` |
| normalize | [Docs](https://sharp.pixelplumbing.com/api-operation#normalize) | `http://localhost:3000/normalize/buffalo.png` |
| threshold | [Docs](https://sharp.pixelplumbing.com/api-operation#threshold) | `http://localhost:3000/threshold_10/buffalo.png` |
| tint | [Docs](https://sharp.pixelplumbing.com/api-colour#tint) | `http://localhost:3000/tint_1098123/buffalo.png` |
| grayscale | [Docs](https://sharp.pixelplumbing.com/api-colour#grayscale) | `http://localhost:3000/grayscale/buffalo.png` |
| animated | - | `http://localhost:3000/animated/buffalo.gif` | Experimental |
| Property | Docs | Example | Comments |
| ----------- | :-------------------------------------------------------------- | :------------------------------------------------------ | :---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| width / w | \_ | `http://localhost:3000/width_200/buffalo.png` |
| height / h | \_ | `http://localhost:3000/height_200/buffalo.png` |
| resize / s | \_ | `http://localhost:3000/s_200x200/buffalo.png` |
| trim | [Docs](https://sharp.pixelplumbing.com/api-resize#trim) | `http://localhost:3000/trim_100/buffalo.png` |
| format | [Docs](https://sharp.pixelplumbing.com/api-output#toformat) | `http://localhost:3000/format_webp/buffalo.png` | Supported format: `jpg`, `jpeg`, `png`, `webp`, `avif`, `gif`, `heif` |
| quality / q | \_ | `http://localhost:3000/quality_50/buffalo.png` | Accepted values: 0 to 100 |
| rotate | [Docs](https://sharp.pixelplumbing.com/api-operation#rotate) | `http://localhost:3000/rotate_45/buffalo.png` |
| enlarge | \_ | `http://localhost:3000/enlarge,s_2000x2000/buffalo.png` | Allow the image to be upscaled. By default the returned image will never be larger than the source in any dimension, while preserving the requested aspect ratio. |
| flip | [Docs](https://sharp.pixelplumbing.com/api-operation#flip) | `http://localhost:3000/flip/buffalo.png` |
| flop | [Docs](https://sharp.pixelplumbing.com/api-operation#flop) | `http://localhost:3000/flop/buffalo.png` |
| sharpen | [Docs](https://sharp.pixelplumbing.com/api-operation#sharpen) | `http://localhost:3000/sharpen_30/buffalo.png` |
| median | [Docs](https://sharp.pixelplumbing.com/api-operation#median) | `http://localhost:3000/median_10/buffalo.png` |
| gamma | [Docs](https://sharp.pixelplumbing.com/api-operation#gamma) | `http://localhost:3000/gamma_3/buffalo.png` |
| negate | [Docs](https://sharp.pixelplumbing.com/api-operation#negate) | `http://localhost:3000/negate/buffalo.png` |
| normalize | [Docs](https://sharp.pixelplumbing.com/api-operation#normalize) | `http://localhost:3000/normalize/buffalo.png` |
| threshold | [Docs](https://sharp.pixelplumbing.com/api-operation#threshold) | `http://localhost:3000/threshold_10/buffalo.png` |
| tint | [Docs](https://sharp.pixelplumbing.com/api-colour#tint) | `http://localhost:3000/tint_1098123/buffalo.png` |
| grayscale | [Docs](https://sharp.pixelplumbing.com/api-colour#grayscale) | `http://localhost:3000/grayscale/buffalo.png` |
| animated | - | `http://localhost:3000/animated/buffalo.gif` | Experimental |

@@ -76,0 +78,0 @@ ### Config

Sorry, the diff of this file is not supported yet

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