mirror of
https://github.com/lovell/sharp.git
synced 2026-02-06 06:36:17 +01:00
Compare commits
19 Commits
v0.34.0-rc
...
v0.34.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5cae1abe8f | ||
|
|
66ffc48707 | ||
|
|
3c7dbb8fba | ||
|
|
a9e191328f | ||
|
|
7323dbee98 | ||
|
|
d7a771ca7a | ||
|
|
7d0585fad1 | ||
|
|
ddc1eb8c4c | ||
|
|
c26e67cc5b | ||
|
|
a00ee26d17 | ||
|
|
6dfb60cda2 | ||
|
|
dbb7606129 | ||
|
|
031c808aa5 | ||
|
|
03e1b19764 | ||
|
|
3e41f8b65e | ||
|
|
3fd818c4b5 | ||
|
|
d419aba76d | ||
|
|
3fb1091114 | ||
|
|
2035492fd9 |
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@@ -208,7 +208,7 @@ jobs:
|
|||||||
contents: write
|
contents: write
|
||||||
name: wasm32 - prebuild
|
name: wasm32 - prebuild
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-24.04
|
||||||
container: "emscripten/emsdk:4.0.5"
|
container: "emscripten/emsdk:4.0.6"
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# sharp
|
# sharp
|
||||||
|
|
||||||
<img src="https://cdn.jsdelivr.net/gh/lovell/sharp@main/docs/image/sharp-logo.svg" width="160" height="160" alt="sharp logo" align="right">
|
<img src="https://cdn.jsdelivr.net/gh/lovell/sharp@main/docs/public/sharp-logo.svg" width="160" height="160" alt="sharp logo" align="right">
|
||||||
|
|
||||||
The typical use case for this high speed Node-API module
|
The typical use case for this high speed Node-API module
|
||||||
is to convert large images in common formats to
|
is to convert large images in common formats to
|
||||||
|
|||||||
@@ -11,99 +11,6 @@
|
|||||||
{ "key": "X-Frame-Options", "value": "SAMEORIGIN" }
|
{ "key": "X-Frame-Options", "value": "SAMEORIGIN" }
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
|
||||||
"redirects": [
|
|
||||||
{
|
|
||||||
"source": "**/install/**",
|
|
||||||
"destination": "/install",
|
|
||||||
"type": 301
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"source": "/page/install",
|
|
||||||
"destination": "/install",
|
|
||||||
"type": 301
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"source": "**/api-constructor/**",
|
|
||||||
"destination": "/api-constructor",
|
|
||||||
"type": 301
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"source": "**/api-input/**",
|
|
||||||
"destination": "/api-input",
|
|
||||||
"type": 301
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"source": "**/api-output/**",
|
|
||||||
"destination": "/api-output",
|
|
||||||
"type": 301
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"source": "**/api-resize/**",
|
|
||||||
"destination": "/api-resize",
|
|
||||||
"type": 301
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"source": "**/api-compsite/**",
|
|
||||||
"destination": "/api-compsite",
|
|
||||||
"type": 301
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"source": "**/api-operation/**",
|
|
||||||
"destination": "/api-operation",
|
|
||||||
"type": 301
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"source": "**/api-colour/**",
|
|
||||||
"destination": "/api-colour",
|
|
||||||
"type": 301
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"source": "**/api-channel/**",
|
|
||||||
"destination": "/api-channel",
|
|
||||||
"type": 301
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"source": "**/api-utility/**",
|
|
||||||
"destination": "/api-utility",
|
|
||||||
"type": 301
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"source": "/page/api",
|
|
||||||
"destination": "/api-constructor",
|
|
||||||
"type": 301
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"source": "**/performance/**",
|
|
||||||
"destination": "/performance",
|
|
||||||
"type": 301
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"source": "/page/performance",
|
|
||||||
"destination": "/performance",
|
|
||||||
"type": 301
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"source": "**/changelog/**",
|
|
||||||
"destination": "/changelog",
|
|
||||||
"type": 301
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"source": "/page/changelog",
|
|
||||||
"destination": "/changelog",
|
|
||||||
"type": 301
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"source": "/en/**",
|
|
||||||
"destination": "/",
|
|
||||||
"type": 301
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"rewrites": [
|
|
||||||
{
|
|
||||||
"source": "**",
|
|
||||||
"destination": "/index.html"
|
|
||||||
}
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
"astro": "astro"
|
"astro": "astro"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@astrojs/starlight": "^0.31.0",
|
"@astrojs/starlight": "^0.32.3",
|
||||||
"astro": "^5.1.7"
|
"astro": "^5.5.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -314,3 +314,6 @@ GitHub: https://github.com/happycollision
|
|||||||
|
|
||||||
Name: Florent Zabera
|
Name: Florent Zabera
|
||||||
GitHub: https://github.com/florentzabera
|
GitHub: https://github.com/florentzabera
|
||||||
|
|
||||||
|
Name: Quentin Pinçon
|
||||||
|
GitHub: https://github.com/qpincon
|
||||||
|
|||||||
@@ -284,6 +284,52 @@ const gaussianBlurred = await sharp(input)
|
|||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## dilate
|
||||||
|
> dilate([width]) ⇒ <code>Sharp</code>
|
||||||
|
|
||||||
|
Expand foreground objects using the dilate morphological operator.
|
||||||
|
|
||||||
|
|
||||||
|
**Throws**:
|
||||||
|
|
||||||
|
- <code>Error</code> Invalid parameters
|
||||||
|
|
||||||
|
|
||||||
|
| Param | Type | Default | Description |
|
||||||
|
| --- | --- | --- | --- |
|
||||||
|
| [width] | <code>Number</code> | <code>1</code> | dilation width in pixels. |
|
||||||
|
|
||||||
|
**Example**
|
||||||
|
```js
|
||||||
|
const output = await sharp(input)
|
||||||
|
.dilate()
|
||||||
|
.toBuffer();
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## erode
|
||||||
|
> erode([width]) ⇒ <code>Sharp</code>
|
||||||
|
|
||||||
|
Shrink foreground objects using the erode morphological operator.
|
||||||
|
|
||||||
|
|
||||||
|
**Throws**:
|
||||||
|
|
||||||
|
- <code>Error</code> Invalid parameters
|
||||||
|
|
||||||
|
|
||||||
|
| Param | Type | Default | Description |
|
||||||
|
| --- | --- | --- | --- |
|
||||||
|
| [width] | <code>Number</code> | <code>1</code> | erosion width in pixels. |
|
||||||
|
|
||||||
|
**Example**
|
||||||
|
```js
|
||||||
|
const output = await sharp(input)
|
||||||
|
.erode()
|
||||||
|
.toBuffer();
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
## flatten
|
## flatten
|
||||||
> flatten([options]) ⇒ <code>Sharp</code>
|
> flatten([options]) ⇒ <code>Sharp</code>
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,13 @@ title: Changelog
|
|||||||
|
|
||||||
Requires libvips v8.16.1
|
Requires libvips v8.16.1
|
||||||
|
|
||||||
### v0.34.0 - TBD
|
### v0.34.1 - 7th April 2025
|
||||||
|
|
||||||
|
* TypeScript: Ensure new `autoOrient` property is optional.
|
||||||
|
[#4362](https://github.com/lovell/sharp/pull/4362)
|
||||||
|
[@styfle](https://github.com/styfle)
|
||||||
|
|
||||||
|
### v0.34.0 - 4th April 2025
|
||||||
|
|
||||||
* Breaking: Support array of input images to be joined or animated.
|
* Breaking: Support array of input images to be joined or animated.
|
||||||
[#1580](https://github.com/lovell/sharp/issues/1580)
|
[#1580](https://github.com/lovell/sharp/issues/1580)
|
||||||
@@ -14,6 +20,9 @@ Requires libvips v8.16.1
|
|||||||
* Breaking: Ensure `removeAlpha` removes all alpha channels.
|
* Breaking: Ensure `removeAlpha` removes all alpha channels.
|
||||||
[#2266](https://github.com/lovell/sharp/issues/2266)
|
[#2266](https://github.com/lovell/sharp/issues/2266)
|
||||||
|
|
||||||
|
* Breaking: Non-animated GIF output defaults to no-loop instead of loop-forever.
|
||||||
|
[#3394](https://github.com/lovell/sharp/issues/3394)
|
||||||
|
|
||||||
* Breaking: Support `info.size` on wide-character systems via upgrade to C++17.
|
* Breaking: Support `info.size` on wide-character systems via upgrade to C++17.
|
||||||
[#3943](https://github.com/lovell/sharp/issues/3943)
|
[#3943](https://github.com/lovell/sharp/issues/3943)
|
||||||
|
|
||||||
@@ -24,6 +33,8 @@ Requires libvips v8.16.1
|
|||||||
|
|
||||||
* Expose WebP `smartDeblock` output option.
|
* Expose WebP `smartDeblock` output option.
|
||||||
|
|
||||||
|
* Prevent use of linux-x64 binaries with v1 microarchitecture.
|
||||||
|
|
||||||
* Add `autoOrient` operation and constructor option.
|
* Add `autoOrient` operation and constructor option.
|
||||||
[#4151](https://github.com/lovell/sharp/pull/4151)
|
[#4151](https://github.com/lovell/sharp/pull/4151)
|
||||||
[@happycollision](https://github.com/happycollision)
|
[@happycollision](https://github.com/happycollision)
|
||||||
@@ -40,10 +51,17 @@ Requires libvips v8.16.1
|
|||||||
[#4207](https://github.com/lovell/sharp/pull/4207)
|
[#4207](https://github.com/lovell/sharp/pull/4207)
|
||||||
[@calebmer](https://github.com/calebmer)
|
[@calebmer](https://github.com/calebmer)
|
||||||
|
|
||||||
|
* Expose erode and dilate operations.
|
||||||
|
[#4243](https://github.com/lovell/sharp/pull/4243)
|
||||||
|
[@qpincon](https://github.com/qpincon)
|
||||||
|
|
||||||
* Add support for RGBE images. Requires libvips compiled with radiance support.
|
* Add support for RGBE images. Requires libvips compiled with radiance support.
|
||||||
[#4316](https://github.com/lovell/sharp/pull/4316)
|
[#4316](https://github.com/lovell/sharp/pull/4316)
|
||||||
[@florentzabera](https://github.com/florentzabera)
|
[@florentzabera](https://github.com/florentzabera)
|
||||||
|
|
||||||
|
* Allow wide-gamut HEIF output at higher bitdepths.
|
||||||
|
[#4344](https://github.com/lovell/sharp/issues/4344)
|
||||||
|
|
||||||
## v0.33 - *gauge*
|
## v0.33 - *gauge*
|
||||||
|
|
||||||
Requires libvips v8.15.3
|
Requires libvips v8.15.3
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
title: "High performance Node.js image processing"
|
title: "High performance Node.js image processing"
|
||||||
---
|
---
|
||||||
|
|
||||||
<img src="https://cdn.jsdelivr.net/gh/lovell/sharp@main/docs/image/sharp-logo.svg" width="160" height="160" alt="sharp logo" align="right">
|
<img src="https://cdn.jsdelivr.net/gh/lovell/sharp@main/docs/public/sharp-logo.svg" width="160" height="160" alt="sharp logo" align="right">
|
||||||
|
|
||||||
The typical use case for this high speed Node-API module
|
The typical use case for this high speed Node-API module
|
||||||
is to convert large images in common formats to
|
is to convert large images in common formats to
|
||||||
|
|||||||
@@ -286,6 +286,10 @@ option.
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
When using `electron-forge` with [Webpack](#webpack),
|
||||||
|
you may also need to add
|
||||||
|
[forge-externals-plugin](https://www.npmjs.com/package/@timfish/forge-externals-plugin).
|
||||||
|
|
||||||
### vite
|
### vite
|
||||||
|
|
||||||
Ensure `sharp` is excluded from bundling via the
|
Ensure `sharp` is excluded from bundling via the
|
||||||
|
|||||||
@@ -263,6 +263,8 @@ const Sharp = function (input, options) {
|
|||||||
trimBackground: [],
|
trimBackground: [],
|
||||||
trimThreshold: -1,
|
trimThreshold: -1,
|
||||||
trimLineArt: false,
|
trimLineArt: false,
|
||||||
|
dilateWidth: 0,
|
||||||
|
erodeWidth: 0,
|
||||||
gamma: 0,
|
gamma: 0,
|
||||||
gammaOut: 0,
|
gammaOut: 0,
|
||||||
greyscale: false,
|
greyscale: false,
|
||||||
@@ -296,6 +298,8 @@ const Sharp = function (input, options) {
|
|||||||
withExif: {},
|
withExif: {},
|
||||||
withExifMerge: true,
|
withExifMerge: true,
|
||||||
resolveWithObject: false,
|
resolveWithObject: false,
|
||||||
|
loop: 1,
|
||||||
|
delay: [],
|
||||||
// output format
|
// output format
|
||||||
jpegQuality: 80,
|
jpegQuality: 80,
|
||||||
jpegProgressive: false,
|
jpegProgressive: false,
|
||||||
|
|||||||
18
lib/index.d.ts
vendored
18
lib/index.d.ts
vendored
@@ -504,6 +504,22 @@ declare namespace sharp {
|
|||||||
*/
|
*/
|
||||||
blur(sigma?: number | boolean | BlurOptions): Sharp;
|
blur(sigma?: number | boolean | BlurOptions): Sharp;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Expand foreground objects using the dilate morphological operator.
|
||||||
|
* @param {Number} [width=1] dilation width in pixels.
|
||||||
|
* @throws {Error} Invalid parameters
|
||||||
|
* @returns A sharp instance that can be used to chain operations
|
||||||
|
*/
|
||||||
|
dilate(width?: number): Sharp;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shrink foreground objects using the erode morphological operator.
|
||||||
|
* @param {Number} [width=1] erosion width in pixels.
|
||||||
|
* @throws {Error} Invalid parameters
|
||||||
|
* @returns A sharp instance that can be used to chain operations
|
||||||
|
*/
|
||||||
|
erode(width?: number): Sharp;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Merge alpha transparency channel, if any, with background.
|
* Merge alpha transparency channel, if any, with background.
|
||||||
* @param flatten true to enable and false to disable (defaults to true)
|
* @param flatten true to enable and false to disable (defaults to true)
|
||||||
@@ -955,7 +971,7 @@ declare namespace sharp {
|
|||||||
*
|
*
|
||||||
* Using this option will remove the EXIF `Orientation` tag, if any.
|
* Using this option will remove the EXIF `Orientation` tag, if any.
|
||||||
*/
|
*/
|
||||||
autoOrient?: boolean;
|
autoOrient?: boolean | undefined;
|
||||||
/**
|
/**
|
||||||
* When to abort processing of invalid pixel data, one of (in order of sensitivity):
|
* When to abort processing of invalid pixel data, one of (in order of sensitivity):
|
||||||
* 'none' (least), 'truncated', 'error' or 'warning' (most), highers level imply lower levels, invalid metadata will always abort. (optional, default 'warning')
|
* 'none' (least), 'truncated', 'error' or 'warning' (most), highers level imply lower levels, invalid metadata will always abort. (optional, default 'warning')
|
||||||
|
|||||||
@@ -113,7 +113,9 @@ const sha512 = (s) => createHash('sha512').update(s).digest('hex');
|
|||||||
const yarnLocator = () => {
|
const yarnLocator = () => {
|
||||||
try {
|
try {
|
||||||
const identHash = sha512(`imgsharp-libvips-${buildPlatformArch()}`);
|
const identHash = sha512(`imgsharp-libvips-${buildPlatformArch()}`);
|
||||||
const npmVersion = semverCoerce(optionalDependencies[`@img/sharp-libvips-${buildPlatformArch()}`]).version;
|
const npmVersion = semverCoerce(optionalDependencies[`@img/sharp-libvips-${buildPlatformArch()}`], {
|
||||||
|
includePrerelease: true
|
||||||
|
}).version;
|
||||||
return sha512(`${identHash}npm:${npmVersion}`).slice(0, 10);
|
return sha512(`${identHash}npm:${npmVersion}`).slice(0, 10);
|
||||||
} catch {}
|
} catch {}
|
||||||
return '';
|
return '';
|
||||||
|
|||||||
@@ -443,6 +443,52 @@ function blur (options) {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Expand foreground objects using the dilate morphological operator.
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* const output = await sharp(input)
|
||||||
|
* .dilate()
|
||||||
|
* .toBuffer();
|
||||||
|
*
|
||||||
|
* @param {Number} [width=1] dilation width in pixels.
|
||||||
|
* @returns {Sharp}
|
||||||
|
* @throws {Error} Invalid parameters
|
||||||
|
*/
|
||||||
|
function dilate (width) {
|
||||||
|
if (!is.defined(width)) {
|
||||||
|
this.options.dilateWidth = 1;
|
||||||
|
} else if (is.integer(width) && width > 0) {
|
||||||
|
this.options.dilateWidth = width;
|
||||||
|
} else {
|
||||||
|
throw is.invalidParameterError('dilate', 'positive integer', dilate);
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shrink foreground objects using the erode morphological operator.
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* const output = await sharp(input)
|
||||||
|
* .erode()
|
||||||
|
* .toBuffer();
|
||||||
|
*
|
||||||
|
* @param {Number} [width=1] erosion width in pixels.
|
||||||
|
* @returns {Sharp}
|
||||||
|
* @throws {Error} Invalid parameters
|
||||||
|
*/
|
||||||
|
function erode (width) {
|
||||||
|
if (!is.defined(width)) {
|
||||||
|
this.options.erodeWidth = 1;
|
||||||
|
} else if (is.integer(width) && width > 0) {
|
||||||
|
this.options.erodeWidth = width;
|
||||||
|
} else {
|
||||||
|
throw is.invalidParameterError('erode', 'positive integer', erode);
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Merge alpha transparency channel, if any, with a background, then remove the alpha channel.
|
* Merge alpha transparency channel, if any, with a background, then remove the alpha channel.
|
||||||
*
|
*
|
||||||
@@ -958,6 +1004,8 @@ module.exports = function (Sharp) {
|
|||||||
flop,
|
flop,
|
||||||
affine,
|
affine,
|
||||||
sharpen,
|
sharpen,
|
||||||
|
erode,
|
||||||
|
dilate,
|
||||||
median,
|
median,
|
||||||
blur,
|
blur,
|
||||||
flatten,
|
flatten,
|
||||||
|
|||||||
12
lib/sharp.js
12
lib/sharp.js
@@ -17,9 +17,9 @@ const paths = [
|
|||||||
'@img/sharp-wasm32/sharp.node'
|
'@img/sharp-wasm32/sharp.node'
|
||||||
];
|
];
|
||||||
|
|
||||||
let sharp;
|
let path, sharp;
|
||||||
const errors = [];
|
const errors = [];
|
||||||
for (const path of paths) {
|
for (path of paths) {
|
||||||
try {
|
try {
|
||||||
sharp = require(path);
|
sharp = require(path);
|
||||||
break;
|
break;
|
||||||
@@ -29,6 +29,14 @@ for (const path of paths) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* istanbul ignore next */
|
||||||
|
if (sharp && path.startsWith('@img/sharp-linux-x64') && !sharp._isUsingX64V2()) {
|
||||||
|
const err = new Error('Prebuilt binaries for linux-x64 require v2 microarchitecture');
|
||||||
|
err.code = 'Unsupported CPU';
|
||||||
|
errors.push(err);
|
||||||
|
sharp = null;
|
||||||
|
}
|
||||||
|
|
||||||
/* istanbul ignore next */
|
/* istanbul ignore next */
|
||||||
if (sharp) {
|
if (sharp) {
|
||||||
module.exports = sharp;
|
module.exports = sharp;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@img/sharp-darwin-arm64",
|
"name": "@img/sharp-darwin-arm64",
|
||||||
"version": "0.34.0-rc.0",
|
"version": "0.34.1",
|
||||||
"description": "Prebuilt sharp for use with macOS 64-bit ARM",
|
"description": "Prebuilt sharp for use with macOS 64-bit ARM",
|
||||||
"author": "Lovell Fuller <npm@lovell.info>",
|
"author": "Lovell Fuller <npm@lovell.info>",
|
||||||
"homepage": "https://sharp.pixelplumbing.com",
|
"homepage": "https://sharp.pixelplumbing.com",
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
},
|
},
|
||||||
"preferUnplugged": true,
|
"preferUnplugged": true,
|
||||||
"optionalDependencies": {
|
"optionalDependencies": {
|
||||||
"@img/sharp-libvips-darwin-arm64": "1.1.0-rc4"
|
"@img/sharp-libvips-darwin-arm64": "1.1.0"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"lib"
|
"lib"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@img/sharp-darwin-x64",
|
"name": "@img/sharp-darwin-x64",
|
||||||
"version": "0.34.0-rc.0",
|
"version": "0.34.1",
|
||||||
"description": "Prebuilt sharp for use with macOS x64",
|
"description": "Prebuilt sharp for use with macOS x64",
|
||||||
"author": "Lovell Fuller <npm@lovell.info>",
|
"author": "Lovell Fuller <npm@lovell.info>",
|
||||||
"homepage": "https://sharp.pixelplumbing.com",
|
"homepage": "https://sharp.pixelplumbing.com",
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
},
|
},
|
||||||
"preferUnplugged": true,
|
"preferUnplugged": true,
|
||||||
"optionalDependencies": {
|
"optionalDependencies": {
|
||||||
"@img/sharp-libvips-darwin-x64": "1.1.0-rc4"
|
"@img/sharp-libvips-darwin-x64": "1.1.0"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"lib"
|
"lib"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@img/sharp-linux-arm",
|
"name": "@img/sharp-linux-arm",
|
||||||
"version": "0.34.0-rc.0",
|
"version": "0.34.1",
|
||||||
"description": "Prebuilt sharp for use with Linux (glibc) ARM (32-bit)",
|
"description": "Prebuilt sharp for use with Linux (glibc) ARM (32-bit)",
|
||||||
"author": "Lovell Fuller <npm@lovell.info>",
|
"author": "Lovell Fuller <npm@lovell.info>",
|
||||||
"homepage": "https://sharp.pixelplumbing.com",
|
"homepage": "https://sharp.pixelplumbing.com",
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
},
|
},
|
||||||
"preferUnplugged": true,
|
"preferUnplugged": true,
|
||||||
"optionalDependencies": {
|
"optionalDependencies": {
|
||||||
"@img/sharp-libvips-linux-arm": "1.1.0-rc4.1"
|
"@img/sharp-libvips-linux-arm": "1.1.0"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"lib"
|
"lib"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@img/sharp-linux-arm64",
|
"name": "@img/sharp-linux-arm64",
|
||||||
"version": "0.34.0-rc.0",
|
"version": "0.34.1",
|
||||||
"description": "Prebuilt sharp for use with Linux (glibc) 64-bit ARM",
|
"description": "Prebuilt sharp for use with Linux (glibc) 64-bit ARM",
|
||||||
"author": "Lovell Fuller <npm@lovell.info>",
|
"author": "Lovell Fuller <npm@lovell.info>",
|
||||||
"homepage": "https://sharp.pixelplumbing.com",
|
"homepage": "https://sharp.pixelplumbing.com",
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
},
|
},
|
||||||
"preferUnplugged": true,
|
"preferUnplugged": true,
|
||||||
"optionalDependencies": {
|
"optionalDependencies": {
|
||||||
"@img/sharp-libvips-linux-arm64": "1.1.0-rc4"
|
"@img/sharp-libvips-linux-arm64": "1.1.0"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"lib"
|
"lib"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@img/sharp-linux-ppc64",
|
"name": "@img/sharp-linux-ppc64",
|
||||||
"version": "0.34.0-rc.0",
|
"version": "0.34.1",
|
||||||
"description": "Prebuilt sharp for use with Linux (glibc) ppc64",
|
"description": "Prebuilt sharp for use with Linux (glibc) ppc64",
|
||||||
"author": "Lovell Fuller <npm@lovell.info>",
|
"author": "Lovell Fuller <npm@lovell.info>",
|
||||||
"homepage": "https://sharp.pixelplumbing.com",
|
"homepage": "https://sharp.pixelplumbing.com",
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
},
|
},
|
||||||
"preferUnplugged": true,
|
"preferUnplugged": true,
|
||||||
"optionalDependencies": {
|
"optionalDependencies": {
|
||||||
"@img/sharp-libvips-linux-ppc64": "1.1.0-rc4"
|
"@img/sharp-libvips-linux-ppc64": "1.1.0"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"lib"
|
"lib"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@img/sharp-linux-s390x",
|
"name": "@img/sharp-linux-s390x",
|
||||||
"version": "0.34.0-rc.0",
|
"version": "0.34.1",
|
||||||
"description": "Prebuilt sharp for use with Linux (glibc) s390x",
|
"description": "Prebuilt sharp for use with Linux (glibc) s390x",
|
||||||
"author": "Lovell Fuller <npm@lovell.info>",
|
"author": "Lovell Fuller <npm@lovell.info>",
|
||||||
"homepage": "https://sharp.pixelplumbing.com",
|
"homepage": "https://sharp.pixelplumbing.com",
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
},
|
},
|
||||||
"preferUnplugged": true,
|
"preferUnplugged": true,
|
||||||
"optionalDependencies": {
|
"optionalDependencies": {
|
||||||
"@img/sharp-libvips-linux-s390x": "1.1.0-rc4"
|
"@img/sharp-libvips-linux-s390x": "1.1.0"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"lib"
|
"lib"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@img/sharp-linux-x64",
|
"name": "@img/sharp-linux-x64",
|
||||||
"version": "0.34.0-rc.0",
|
"version": "0.34.1",
|
||||||
"description": "Prebuilt sharp for use with Linux (glibc) x64",
|
"description": "Prebuilt sharp for use with Linux (glibc) x64",
|
||||||
"author": "Lovell Fuller <npm@lovell.info>",
|
"author": "Lovell Fuller <npm@lovell.info>",
|
||||||
"homepage": "https://sharp.pixelplumbing.com",
|
"homepage": "https://sharp.pixelplumbing.com",
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
},
|
},
|
||||||
"preferUnplugged": true,
|
"preferUnplugged": true,
|
||||||
"optionalDependencies": {
|
"optionalDependencies": {
|
||||||
"@img/sharp-libvips-linux-x64": "1.1.0-rc4"
|
"@img/sharp-libvips-linux-x64": "1.1.0"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"lib"
|
"lib"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@img/sharp-linuxmusl-arm64",
|
"name": "@img/sharp-linuxmusl-arm64",
|
||||||
"version": "0.34.0-rc.0",
|
"version": "0.34.1",
|
||||||
"description": "Prebuilt sharp for use with Linux (musl) 64-bit ARM",
|
"description": "Prebuilt sharp for use with Linux (musl) 64-bit ARM",
|
||||||
"author": "Lovell Fuller <npm@lovell.info>",
|
"author": "Lovell Fuller <npm@lovell.info>",
|
||||||
"homepage": "https://sharp.pixelplumbing.com",
|
"homepage": "https://sharp.pixelplumbing.com",
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
},
|
},
|
||||||
"preferUnplugged": true,
|
"preferUnplugged": true,
|
||||||
"optionalDependencies": {
|
"optionalDependencies": {
|
||||||
"@img/sharp-libvips-linuxmusl-arm64": "1.1.0-rc4"
|
"@img/sharp-libvips-linuxmusl-arm64": "1.1.0"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"lib"
|
"lib"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@img/sharp-linuxmusl-x64",
|
"name": "@img/sharp-linuxmusl-x64",
|
||||||
"version": "0.34.0-rc.0",
|
"version": "0.34.1",
|
||||||
"description": "Prebuilt sharp for use with Linux (musl) x64",
|
"description": "Prebuilt sharp for use with Linux (musl) x64",
|
||||||
"author": "Lovell Fuller <npm@lovell.info>",
|
"author": "Lovell Fuller <npm@lovell.info>",
|
||||||
"homepage": "https://sharp.pixelplumbing.com",
|
"homepage": "https://sharp.pixelplumbing.com",
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
},
|
},
|
||||||
"preferUnplugged": true,
|
"preferUnplugged": true,
|
||||||
"optionalDependencies": {
|
"optionalDependencies": {
|
||||||
"@img/sharp-libvips-linuxmusl-x64": "1.1.0-rc4"
|
"@img/sharp-libvips-linuxmusl-x64": "1.1.0"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"lib"
|
"lib"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@img/sharp",
|
"name": "@img/sharp",
|
||||||
"version": "0.34.0-rc.0",
|
"version": "0.34.1",
|
||||||
"private": "true",
|
"private": "true",
|
||||||
"workspaces": [
|
"workspaces": [
|
||||||
"darwin-arm64",
|
"darwin-arm64",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@img/sharp-wasm32",
|
"name": "@img/sharp-wasm32",
|
||||||
"version": "0.34.0-rc.0",
|
"version": "0.34.1",
|
||||||
"description": "Prebuilt sharp for use with wasm32",
|
"description": "Prebuilt sharp for use with wasm32",
|
||||||
"author": "Lovell Fuller <npm@lovell.info>",
|
"author": "Lovell Fuller <npm@lovell.info>",
|
||||||
"homepage": "https://sharp.pixelplumbing.com",
|
"homepage": "https://sharp.pixelplumbing.com",
|
||||||
@@ -31,7 +31,7 @@
|
|||||||
"node": "^18.17.0 || ^20.3.0 || >=21.0.0"
|
"node": "^18.17.0 || ^20.3.0 || >=21.0.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@emnapi/runtime": "^1.3.1"
|
"@emnapi/runtime": "^1.4.0"
|
||||||
},
|
},
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"wasm32"
|
"wasm32"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@img/sharp-win32-ia32",
|
"name": "@img/sharp-win32-ia32",
|
||||||
"version": "0.34.0-rc.0",
|
"version": "0.34.1",
|
||||||
"description": "Prebuilt sharp for use with Windows x86 (32-bit)",
|
"description": "Prebuilt sharp for use with Windows x86 (32-bit)",
|
||||||
"author": "Lovell Fuller <npm@lovell.info>",
|
"author": "Lovell Fuller <npm@lovell.info>",
|
||||||
"homepage": "https://sharp.pixelplumbing.com",
|
"homepage": "https://sharp.pixelplumbing.com",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@img/sharp-win32-x64",
|
"name": "@img/sharp-win32-x64",
|
||||||
"version": "0.34.0-rc.0",
|
"version": "0.34.1",
|
||||||
"description": "Prebuilt sharp for use with Windows x64",
|
"description": "Prebuilt sharp for use with Windows x64",
|
||||||
"author": "Lovell Fuller <npm@lovell.info>",
|
"author": "Lovell Fuller <npm@lovell.info>",
|
||||||
"homepage": "https://sharp.pixelplumbing.com",
|
"homepage": "https://sharp.pixelplumbing.com",
|
||||||
|
|||||||
54
package.json
54
package.json
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "sharp",
|
"name": "sharp",
|
||||||
"description": "High performance Node.js image processing, the fastest module to resize JPEG, PNG, WebP, GIF, AVIF and TIFF images",
|
"description": "High performance Node.js image processing, the fastest module to resize JPEG, PNG, WebP, GIF, AVIF and TIFF images",
|
||||||
"version": "0.34.0-rc.0",
|
"version": "0.34.1",
|
||||||
"author": "Lovell Fuller <npm@lovell.info>",
|
"author": "Lovell Fuller <npm@lovell.info>",
|
||||||
"homepage": "https://sharp.pixelplumbing.com",
|
"homepage": "https://sharp.pixelplumbing.com",
|
||||||
"contributors": [
|
"contributors": [
|
||||||
@@ -142,36 +142,36 @@
|
|||||||
"semver": "^7.7.1"
|
"semver": "^7.7.1"
|
||||||
},
|
},
|
||||||
"optionalDependencies": {
|
"optionalDependencies": {
|
||||||
"@img/sharp-darwin-arm64": "0.34.0-rc.0",
|
"@img/sharp-darwin-arm64": "0.34.1",
|
||||||
"@img/sharp-darwin-x64": "0.34.0-rc.0",
|
"@img/sharp-darwin-x64": "0.34.1",
|
||||||
"@img/sharp-libvips-darwin-arm64": "1.1.0-rc4",
|
"@img/sharp-libvips-darwin-arm64": "1.1.0",
|
||||||
"@img/sharp-libvips-darwin-x64": "1.1.0-rc4",
|
"@img/sharp-libvips-darwin-x64": "1.1.0",
|
||||||
"@img/sharp-libvips-linux-arm": "1.1.0-rc4.1",
|
"@img/sharp-libvips-linux-arm": "1.1.0",
|
||||||
"@img/sharp-libvips-linux-arm64": "1.1.0-rc4",
|
"@img/sharp-libvips-linux-arm64": "1.1.0",
|
||||||
"@img/sharp-libvips-linux-ppc64": "1.1.0-rc4",
|
"@img/sharp-libvips-linux-ppc64": "1.1.0",
|
||||||
"@img/sharp-libvips-linux-s390x": "1.1.0-rc4",
|
"@img/sharp-libvips-linux-s390x": "1.1.0",
|
||||||
"@img/sharp-libvips-linux-x64": "1.1.0-rc4",
|
"@img/sharp-libvips-linux-x64": "1.1.0",
|
||||||
"@img/sharp-libvips-linuxmusl-arm64": "1.1.0-rc4",
|
"@img/sharp-libvips-linuxmusl-arm64": "1.1.0",
|
||||||
"@img/sharp-libvips-linuxmusl-x64": "1.1.0-rc4",
|
"@img/sharp-libvips-linuxmusl-x64": "1.1.0",
|
||||||
"@img/sharp-linux-arm": "0.34.0-rc.0",
|
"@img/sharp-linux-arm": "0.34.1",
|
||||||
"@img/sharp-linux-arm64": "0.34.0-rc.0",
|
"@img/sharp-linux-arm64": "0.34.1",
|
||||||
"@img/sharp-linux-s390x": "0.34.0-rc.0",
|
"@img/sharp-linux-s390x": "0.34.1",
|
||||||
"@img/sharp-linux-x64": "0.34.0-rc.0",
|
"@img/sharp-linux-x64": "0.34.1",
|
||||||
"@img/sharp-linuxmusl-arm64": "0.34.0-rc.0",
|
"@img/sharp-linuxmusl-arm64": "0.34.1",
|
||||||
"@img/sharp-linuxmusl-x64": "0.34.0-rc.0",
|
"@img/sharp-linuxmusl-x64": "0.34.1",
|
||||||
"@img/sharp-wasm32": "0.34.0-rc.0",
|
"@img/sharp-wasm32": "0.34.1",
|
||||||
"@img/sharp-win32-ia32": "0.34.0-rc.0",
|
"@img/sharp-win32-ia32": "0.34.1",
|
||||||
"@img/sharp-win32-x64": "0.34.0-rc.0"
|
"@img/sharp-win32-x64": "0.34.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@emnapi/runtime": "^1.3.1",
|
"@emnapi/runtime": "^1.4.0",
|
||||||
"@img/sharp-libvips-dev": "1.1.0-rc4",
|
"@img/sharp-libvips-dev": "1.1.0",
|
||||||
"@img/sharp-libvips-dev-wasm32": "1.1.0-rc4",
|
"@img/sharp-libvips-dev-wasm32": "1.1.0",
|
||||||
"@img/sharp-libvips-win32-ia32": "1.1.0-rc4",
|
"@img/sharp-libvips-win32-ia32": "1.1.0",
|
||||||
"@img/sharp-libvips-win32-x64": "1.1.0-rc4",
|
"@img/sharp-libvips-win32-x64": "1.1.0",
|
||||||
"@types/node": "*",
|
"@types/node": "*",
|
||||||
"cc": "^3.0.1",
|
"cc": "^3.0.1",
|
||||||
"emnapi": "^1.3.1",
|
"emnapi": "^1.4.0",
|
||||||
"exif-reader": "^2.0.2",
|
"exif-reader": "^2.0.2",
|
||||||
"extract-zip": "^2.0.1",
|
"extract-zip": "^2.0.1",
|
||||||
"icc": "^3.0.0",
|
"icc": "^3.0.0",
|
||||||
|
|||||||
@@ -19,7 +19,10 @@
|
|||||||
'type': 'shared_library',
|
'type': 'shared_library',
|
||||||
'defines': [
|
'defines': [
|
||||||
'_VIPS_PUBLIC=__declspec(dllexport)',
|
'_VIPS_PUBLIC=__declspec(dllexport)',
|
||||||
'_ALLOW_KEYWORD_MACROS'
|
'_ALLOW_KEYWORD_MACROS',
|
||||||
|
'G_DISABLE_ASSERT',
|
||||||
|
'G_DISABLE_CAST_CHECKS',
|
||||||
|
'G_DISABLE_CHECKS'
|
||||||
],
|
],
|
||||||
'sources': [
|
'sources': [
|
||||||
'<(sharp_libvips_cplusplus_dir)/VConnection.cpp',
|
'<(sharp_libvips_cplusplus_dir)/VConnection.cpp',
|
||||||
@@ -80,6 +83,9 @@
|
|||||||
}, {
|
}, {
|
||||||
'target_name': 'sharp-<(platform_and_arch)',
|
'target_name': 'sharp-<(platform_and_arch)',
|
||||||
'defines': [
|
'defines': [
|
||||||
|
'G_DISABLE_ASSERT',
|
||||||
|
'G_DISABLE_CAST_CHECKS',
|
||||||
|
'G_DISABLE_CHECKS',
|
||||||
'NAPI_VERSION=9',
|
'NAPI_VERSION=9',
|
||||||
'NODE_ADDON_API_DISABLE_DEPRECATED',
|
'NODE_ADDON_API_DISABLE_DEPRECATED',
|
||||||
'NODE_API_SWALLOW_UNTHROWABLE_EXCEPTIONS'
|
'NODE_API_SWALLOW_UNTHROWABLE_EXCEPTIONS'
|
||||||
@@ -179,6 +185,7 @@
|
|||||||
'-Wl,-s',
|
'-Wl,-s',
|
||||||
'-Wl,--disable-new-dtags',
|
'-Wl,--disable-new-dtags',
|
||||||
'-Wl,-z,nodelete',
|
'-Wl,-z,nodelete',
|
||||||
|
'-Wl,-Bsymbolic-functions',
|
||||||
'-Wl,-rpath=\'$$ORIGIN/../../sharp-libvips-<(platform_and_arch)/lib\'',
|
'-Wl,-rpath=\'$$ORIGIN/../../sharp-libvips-<(platform_and_arch)/lib\'',
|
||||||
'-Wl,-rpath=\'$$ORIGIN/../../../sharp-libvips-<(platform_and_arch)/<(sharp_libvips_version)/lib\'',
|
'-Wl,-rpath=\'$$ORIGIN/../../../sharp-libvips-<(platform_and_arch)/<(sharp_libvips_version)/lib\'',
|
||||||
'-Wl,-rpath=\'$$ORIGIN/../../node_modules/@img/sharp-libvips-<(platform_and_arch)/lib\'',
|
'-Wl,-rpath=\'$$ORIGIN/../../node_modules/@img/sharp-libvips-<(platform_and_arch)/lib\'',
|
||||||
|
|||||||
@@ -472,4 +472,26 @@ namespace sharp {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Dilate an image
|
||||||
|
*/
|
||||||
|
VImage Dilate(VImage image, int const width) {
|
||||||
|
int const maskWidth = 2 * width + 1;
|
||||||
|
VImage mask = VImage::new_matrix(maskWidth, maskWidth);
|
||||||
|
return image.morph(
|
||||||
|
mask,
|
||||||
|
VIPS_OPERATION_MORPHOLOGY_DILATE).invert();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Erode an image
|
||||||
|
*/
|
||||||
|
VImage Erode(VImage image, int const width) {
|
||||||
|
int const maskWidth = 2 * width + 1;
|
||||||
|
VImage mask = VImage::new_matrix(maskWidth, maskWidth);
|
||||||
|
return image.morph(
|
||||||
|
mask,
|
||||||
|
VIPS_OPERATION_MORPHOLOGY_ERODE).invert();
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace sharp
|
} // namespace sharp
|
||||||
|
|||||||
@@ -120,6 +120,15 @@ namespace sharp {
|
|||||||
VImage EmbedMultiPage(VImage image, int left, int top, int width, int height,
|
VImage EmbedMultiPage(VImage image, int left, int top, int width, int height,
|
||||||
VipsExtend extendWith, std::vector<double> background, int nPages, int *pageHeight);
|
VipsExtend extendWith, std::vector<double> background, int nPages, int *pageHeight);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Dilate an image
|
||||||
|
*/
|
||||||
|
VImage Dilate(VImage image, int const maskWidth);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Erode an image
|
||||||
|
*/
|
||||||
|
VImage Erode(VImage image, int const maskWidth);
|
||||||
} // namespace sharp
|
} // namespace sharp
|
||||||
|
|
||||||
#endif // SRC_OPERATIONS_H_
|
#endif // SRC_OPERATIONS_H_
|
||||||
|
|||||||
@@ -609,6 +609,16 @@ class PipelineWorker : public Napi::AsyncWorker {
|
|||||||
image = sharp::Threshold(image, baton->threshold, baton->thresholdGrayscale);
|
image = sharp::Threshold(image, baton->threshold, baton->thresholdGrayscale);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Dilate - must happen before blurring, due to the utility of dilating after thresholding
|
||||||
|
if (baton->dilateWidth != 0) {
|
||||||
|
image = sharp::Dilate(image, baton->dilateWidth);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Erode - must happen before blurring, due to the utility of eroding after thresholding
|
||||||
|
if (baton->erodeWidth != 0) {
|
||||||
|
image = sharp::Erode(image, baton->erodeWidth);
|
||||||
|
}
|
||||||
|
|
||||||
// Blur
|
// Blur
|
||||||
if (shouldBlur) {
|
if (shouldBlur) {
|
||||||
image = sharp::Blur(image, baton->blurSigma, baton->precision, baton->minAmpl);
|
image = sharp::Blur(image, baton->blurSigma, baton->precision, baton->minAmpl);
|
||||||
@@ -1032,7 +1042,7 @@ class PipelineWorker : public Napi::AsyncWorker {
|
|||||||
(baton->formatOut == "input" && inputImageType == sharp::ImageType::HEIF)) {
|
(baton->formatOut == "input" && inputImageType == sharp::ImageType::HEIF)) {
|
||||||
// Write HEIF to buffer
|
// Write HEIF to buffer
|
||||||
sharp::AssertImageTypeDimensions(image, sharp::ImageType::HEIF);
|
sharp::AssertImageTypeDimensions(image, sharp::ImageType::HEIF);
|
||||||
image = sharp::RemoveAnimationProperties(image).cast(VIPS_FORMAT_UCHAR);
|
image = sharp::RemoveAnimationProperties(image);
|
||||||
VipsArea *area = reinterpret_cast<VipsArea*>(image.heifsave_buffer(VImage::option()
|
VipsArea *area = reinterpret_cast<VipsArea*>(image.heifsave_buffer(VImage::option()
|
||||||
->set("keep", baton->keepMetadata)
|
->set("keep", baton->keepMetadata)
|
||||||
->set("Q", baton->heifQuality)
|
->set("Q", baton->heifQuality)
|
||||||
@@ -1227,7 +1237,7 @@ class PipelineWorker : public Napi::AsyncWorker {
|
|||||||
(willMatchInput && inputImageType == sharp::ImageType::HEIF)) {
|
(willMatchInput && inputImageType == sharp::ImageType::HEIF)) {
|
||||||
// Write HEIF to file
|
// Write HEIF to file
|
||||||
sharp::AssertImageTypeDimensions(image, sharp::ImageType::HEIF);
|
sharp::AssertImageTypeDimensions(image, sharp::ImageType::HEIF);
|
||||||
image = sharp::RemoveAnimationProperties(image).cast(VIPS_FORMAT_UCHAR);
|
image = sharp::RemoveAnimationProperties(image);
|
||||||
image.heifsave(const_cast<char*>(baton->fileOut.data()), VImage::option()
|
image.heifsave(const_cast<char*>(baton->fileOut.data()), VImage::option()
|
||||||
->set("keep", baton->keepMetadata)
|
->set("keep", baton->keepMetadata)
|
||||||
->set("Q", baton->heifQuality)
|
->set("Q", baton->heifQuality)
|
||||||
@@ -1621,6 +1631,8 @@ Napi::Value pipeline(const Napi::CallbackInfo& info) {
|
|||||||
baton->gammaOut = sharp::AttrAsDouble(options, "gammaOut");
|
baton->gammaOut = sharp::AttrAsDouble(options, "gammaOut");
|
||||||
baton->linearA = sharp::AttrAsVectorOfDouble(options, "linearA");
|
baton->linearA = sharp::AttrAsVectorOfDouble(options, "linearA");
|
||||||
baton->linearB = sharp::AttrAsVectorOfDouble(options, "linearB");
|
baton->linearB = sharp::AttrAsVectorOfDouble(options, "linearB");
|
||||||
|
baton->dilateWidth = sharp::AttrAsUint32(options, "dilateWidth");
|
||||||
|
baton->erodeWidth = sharp::AttrAsUint32(options, "erodeWidth");
|
||||||
baton->greyscale = sharp::AttrAsBool(options, "greyscale");
|
baton->greyscale = sharp::AttrAsBool(options, "greyscale");
|
||||||
baton->normalise = sharp::AttrAsBool(options, "normalise");
|
baton->normalise = sharp::AttrAsBool(options, "normalise");
|
||||||
baton->normaliseLower = sharp::AttrAsUint32(options, "normaliseLower");
|
baton->normaliseLower = sharp::AttrAsUint32(options, "normaliseLower");
|
||||||
@@ -1705,6 +1717,8 @@ Napi::Value pipeline(const Napi::CallbackInfo& info) {
|
|||||||
}
|
}
|
||||||
baton->withExifMerge = sharp::AttrAsBool(options, "withExifMerge");
|
baton->withExifMerge = sharp::AttrAsBool(options, "withExifMerge");
|
||||||
baton->timeoutSeconds = sharp::AttrAsUint32(options, "timeoutSeconds");
|
baton->timeoutSeconds = sharp::AttrAsUint32(options, "timeoutSeconds");
|
||||||
|
baton->loop = sharp::AttrAsUint32(options, "loop");
|
||||||
|
baton->delay = sharp::AttrAsInt32Vector(options, "delay");
|
||||||
// Format-specific
|
// Format-specific
|
||||||
baton->jpegQuality = sharp::AttrAsUint32(options, "jpegQuality");
|
baton->jpegQuality = sharp::AttrAsUint32(options, "jpegQuality");
|
||||||
baton->jpegProgressive = sharp::AttrAsBool(options, "jpegProgressive");
|
baton->jpegProgressive = sharp::AttrAsBool(options, "jpegProgressive");
|
||||||
@@ -1774,13 +1788,6 @@ Napi::Value pipeline(const Napi::CallbackInfo& info) {
|
|||||||
baton->jxlEffort = sharp::AttrAsUint32(options, "jxlEffort");
|
baton->jxlEffort = sharp::AttrAsUint32(options, "jxlEffort");
|
||||||
baton->jxlLossless = sharp::AttrAsBool(options, "jxlLossless");
|
baton->jxlLossless = sharp::AttrAsBool(options, "jxlLossless");
|
||||||
baton->rawDepth = sharp::AttrAsEnum<VipsBandFormat>(options, "rawDepth", VIPS_TYPE_BAND_FORMAT);
|
baton->rawDepth = sharp::AttrAsEnum<VipsBandFormat>(options, "rawDepth", VIPS_TYPE_BAND_FORMAT);
|
||||||
// Animated output properties
|
|
||||||
if (sharp::HasAttr(options, "loop")) {
|
|
||||||
baton->loop = sharp::AttrAsUint32(options, "loop");
|
|
||||||
}
|
|
||||||
if (sharp::HasAttr(options, "delay")) {
|
|
||||||
baton->delay = sharp::AttrAsInt32Vector(options, "delay");
|
|
||||||
}
|
|
||||||
baton->tileSize = sharp::AttrAsUint32(options, "tileSize");
|
baton->tileSize = sharp::AttrAsUint32(options, "tileSize");
|
||||||
baton->tileOverlap = sharp::AttrAsUint32(options, "tileOverlap");
|
baton->tileOverlap = sharp::AttrAsUint32(options, "tileOverlap");
|
||||||
baton->tileAngle = sharp::AttrAsInt32(options, "tileAngle");
|
baton->tileAngle = sharp::AttrAsInt32(options, "tileAngle");
|
||||||
|
|||||||
@@ -101,6 +101,8 @@ struct PipelineBaton {
|
|||||||
int trimOffsetTop;
|
int trimOffsetTop;
|
||||||
std::vector<double> linearA;
|
std::vector<double> linearA;
|
||||||
std::vector<double> linearB;
|
std::vector<double> linearB;
|
||||||
|
int dilateWidth;
|
||||||
|
int erodeWidth;
|
||||||
double gamma;
|
double gamma;
|
||||||
double gammaOut;
|
double gammaOut;
|
||||||
bool greyscale;
|
bool greyscale;
|
||||||
@@ -274,6 +276,8 @@ struct PipelineBaton {
|
|||||||
trimOffsetTop(0),
|
trimOffsetTop(0),
|
||||||
linearA{},
|
linearA{},
|
||||||
linearB{},
|
linearB{},
|
||||||
|
dilateWidth(0),
|
||||||
|
erodeWidth(0),
|
||||||
gamma(0.0),
|
gamma(0.0),
|
||||||
greyscale(false),
|
greyscale(false),
|
||||||
normalise(false),
|
normalise(false),
|
||||||
@@ -380,7 +384,7 @@ struct PipelineBaton {
|
|||||||
ensureAlpha(-1.0),
|
ensureAlpha(-1.0),
|
||||||
colourspacePipeline(VIPS_INTERPRETATION_LAST),
|
colourspacePipeline(VIPS_INTERPRETATION_LAST),
|
||||||
colourspace(VIPS_INTERPRETATION_LAST),
|
colourspace(VIPS_INTERPRETATION_LAST),
|
||||||
loop(-1),
|
loop(1),
|
||||||
tileSize(256),
|
tileSize(256),
|
||||||
tileOverlap(0),
|
tileOverlap(0),
|
||||||
tileContainer(VIPS_FOREIGN_DZ_CONTAINER_FS),
|
tileContainer(VIPS_FOREIGN_DZ_CONTAINER_FS),
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ Napi::Object init(Napi::Env env, Napi::Object exports) {
|
|||||||
exports.Set("block", Napi::Function::New(env, block));
|
exports.Set("block", Napi::Function::New(env, block));
|
||||||
exports.Set("_maxColourDistance", Napi::Function::New(env, _maxColourDistance));
|
exports.Set("_maxColourDistance", Napi::Function::New(env, _maxColourDistance));
|
||||||
exports.Set("_isUsingJemalloc", Napi::Function::New(env, _isUsingJemalloc));
|
exports.Set("_isUsingJemalloc", Napi::Function::New(env, _isUsingJemalloc));
|
||||||
|
exports.Set("_isUsingX64V2", Napi::Function::New(env, _isUsingX64V2));
|
||||||
exports.Set("stats", Napi::Function::New(env, stats));
|
exports.Set("stats", Napi::Function::New(env, stats));
|
||||||
return exports;
|
return exports;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -267,3 +267,20 @@ Napi::Value _isUsingJemalloc(const Napi::CallbackInfo& info) {
|
|||||||
return Napi::Boolean::New(env, false);
|
return Napi::Boolean::New(env, false);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(__GNUC__) && defined(__x86_64__)
|
||||||
|
// Are SSE 4.2 intrinsics available at runtime?
|
||||||
|
Napi::Value _isUsingX64V2(const Napi::CallbackInfo& info) {
|
||||||
|
Napi::Env env = info.Env();
|
||||||
|
unsigned int eax, ebx, ecx, edx;
|
||||||
|
__asm__ __volatile__("cpuid"
|
||||||
|
: "=a"(eax), "=b"(ebx), "=c"(ecx), "=d"(edx)
|
||||||
|
: "a"(1));
|
||||||
|
return Napi::Boolean::New(env, (ecx & 1U << 20) != 0);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
Napi::Value _isUsingX64V2(const Napi::CallbackInfo& info) {
|
||||||
|
Napi::Env env = info.Env();
|
||||||
|
return Napi::Boolean::New(env, false);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|||||||
@@ -15,5 +15,6 @@ Napi::Value format(const Napi::CallbackInfo& info);
|
|||||||
void block(const Napi::CallbackInfo& info);
|
void block(const Napi::CallbackInfo& info);
|
||||||
Napi::Value _maxColourDistance(const Napi::CallbackInfo& info);
|
Napi::Value _maxColourDistance(const Napi::CallbackInfo& info);
|
||||||
Napi::Value _isUsingJemalloc(const Napi::CallbackInfo& info);
|
Napi::Value _isUsingJemalloc(const Napi::CallbackInfo& info);
|
||||||
|
Napi::Value _isUsingX64V2(const Napi::CallbackInfo& info);
|
||||||
|
|
||||||
#endif // SRC_UTILITIES_H_
|
#endif // SRC_UTILITIES_H_
|
||||||
|
|||||||
BIN
test/fixtures/dot-and-lines.png
vendored
Normal file
BIN
test/fixtures/dot-and-lines.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 463 B |
BIN
test/fixtures/expected/dilate-1.png
vendored
Normal file
BIN
test/fixtures/expected/dilate-1.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 540 B |
BIN
test/fixtures/expected/erode-1.png
vendored
Normal file
BIN
test/fixtures/expected/erode-1.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 450 B |
2
test/fixtures/index.js
vendored
2
test/fixtures/index.js
vendored
@@ -128,6 +128,8 @@ module.exports = {
|
|||||||
|
|
||||||
inputJPGBig: getPath('flowers.jpeg'),
|
inputJPGBig: getPath('flowers.jpeg'),
|
||||||
|
|
||||||
|
inputPngDotAndLines: getPath('dot-and-lines.png'),
|
||||||
|
|
||||||
inputPngStripesV: getPath('stripesV.png'),
|
inputPngStripesV: getPath('stripesV.png'),
|
||||||
inputPngStripesH: getPath('stripesH.png'),
|
inputPngStripesH: getPath('stripesH.png'),
|
||||||
|
|
||||||
|
|||||||
@@ -740,3 +740,8 @@ sharp([input, input], {
|
|||||||
valign: 'bottom'
|
valign: 'bottom'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
sharp().erode();
|
||||||
|
sharp().erode(1);
|
||||||
|
sharp().dilate();
|
||||||
|
sharp().dilate(1);
|
||||||
|
|||||||
38
test/unit/dilate.js
Normal file
38
test/unit/dilate.js
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
const assert = require('assert');
|
||||||
|
|
||||||
|
const sharp = require('../../');
|
||||||
|
const fixtures = require('../fixtures');
|
||||||
|
|
||||||
|
describe('Dilate', function () {
|
||||||
|
it('dilate 1 png', function (done) {
|
||||||
|
sharp(fixtures.inputPngDotAndLines)
|
||||||
|
.dilate(1)
|
||||||
|
.toBuffer(function (err, data, info) {
|
||||||
|
if (err) throw err;
|
||||||
|
assert.strictEqual('png', info.format);
|
||||||
|
assert.strictEqual(100, info.width);
|
||||||
|
assert.strictEqual(100, info.height);
|
||||||
|
fixtures.assertSimilar(fixtures.expected('dilate-1.png'), data, done);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('dilate 1 png - default width', function (done) {
|
||||||
|
sharp(fixtures.inputPngDotAndLines)
|
||||||
|
.dilate()
|
||||||
|
.toBuffer(function (err, data, info) {
|
||||||
|
if (err) throw err;
|
||||||
|
assert.strictEqual('png', info.format);
|
||||||
|
assert.strictEqual(100, info.width);
|
||||||
|
assert.strictEqual(100, info.height);
|
||||||
|
fixtures.assertSimilar(fixtures.expected('dilate-1.png'), data, done);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('invalid dilation width', function () {
|
||||||
|
assert.throws(function () {
|
||||||
|
sharp(fixtures.inputJpg).dilate(-1);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
38
test/unit/erode.js
Normal file
38
test/unit/erode.js
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
const assert = require('assert');
|
||||||
|
|
||||||
|
const sharp = require('../../');
|
||||||
|
const fixtures = require('../fixtures');
|
||||||
|
|
||||||
|
describe('Erode', function () {
|
||||||
|
it('erode 1 png', function (done) {
|
||||||
|
sharp(fixtures.inputPngDotAndLines)
|
||||||
|
.erode(1)
|
||||||
|
.toBuffer(function (err, data, info) {
|
||||||
|
if (err) throw err;
|
||||||
|
assert.strictEqual('png', info.format);
|
||||||
|
assert.strictEqual(100, info.width);
|
||||||
|
assert.strictEqual(100, info.height);
|
||||||
|
fixtures.assertSimilar(fixtures.expected('erode-1.png'), data, done);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('erode 1 png - default width', function (done) {
|
||||||
|
sharp(fixtures.inputPngDotAndLines)
|
||||||
|
.erode()
|
||||||
|
.toBuffer(function (err, data, info) {
|
||||||
|
if (err) throw err;
|
||||||
|
assert.strictEqual('png', info.format);
|
||||||
|
assert.strictEqual(100, info.width);
|
||||||
|
assert.strictEqual(100, info.height);
|
||||||
|
fixtures.assertSimilar(fixtures.expected('erode-1.png'), data, done);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('invalid erosion width', function () {
|
||||||
|
assert.throws(function () {
|
||||||
|
sharp(fixtures.inputJpg).erode(-1);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -224,4 +224,18 @@ describe('GIF input', () => {
|
|||||||
const after = await input.gif({ interPaletteMaxError: 100 }).toBuffer();
|
const after = await input.gif({ interPaletteMaxError: 100 }).toBuffer();
|
||||||
assert.strict(before.length > after.length);
|
assert.strict(before.length > after.length);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('non-animated input defaults to no-loop', async () => {
|
||||||
|
for (const input of [fixtures.inputGif, fixtures.inputPng]) {
|
||||||
|
const data = await sharp(input)
|
||||||
|
.resize(8)
|
||||||
|
.gif({ effort: 1 })
|
||||||
|
.toBuffer();
|
||||||
|
|
||||||
|
const { format, pages, loop } = await sharp(data).metadata();
|
||||||
|
assert.strictEqual('gif', format);
|
||||||
|
assert.strictEqual(1, pages);
|
||||||
|
assert.strictEqual(1, loop);
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user