@guru-ai-product/ai-product-kit 0.2.251113194913 → 0.2.251113205658
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/mcp/skills/aipk_init_project/template/AGENTS_TEMPLATE.md +1 -1
- package/mcp/src/server.js +1 -1
- package/package.json +1 -1
- package/skills/aipk_design/GURU_AI.md +119 -7
- package/skills/aipk_design/SKILL.md +8 -7
- package/skills/aipk_design/{auto_panel_splitter → update-requirements-from-design}/SKILL.md +18 -16
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/.package-lock.json +113 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/@img/colour/LICENSE.md +82 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/@img/colour/README.md +15 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/@img/colour/color.cjs +1594 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/@img/colour/index.cjs +1 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/@img/colour/package.json +45 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/@img/sharp-darwin-arm64/LICENSE +191 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/@img/sharp-darwin-arm64/README.md +18 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/@img/sharp-darwin-arm64/lib/sharp-darwin-arm64.node +0 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/@img/sharp-darwin-arm64/package.json +40 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/@img/sharp-libvips-darwin-arm64/README.md +46 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/@img/sharp-libvips-darwin-arm64/lib/glib-2.0/include/glibconfig.h +220 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/@img/sharp-libvips-darwin-arm64/lib/index.js +1 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/@img/sharp-libvips-darwin-arm64/lib/libvips-cpp.8.17.3.dylib +0 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/@img/sharp-libvips-darwin-arm64/package.json +36 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/@img/sharp-libvips-darwin-arm64/versions.json +30 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/detect-libc/LICENSE +201 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/detect-libc/README.md +163 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/detect-libc/index.d.ts +14 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/detect-libc/lib/detect-libc.js +313 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/detect-libc/lib/elf.js +39 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/detect-libc/lib/filesystem.js +51 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/detect-libc/lib/process.js +24 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/detect-libc/package.json +44 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/LICENSE +15 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/README.md +664 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/bin/semver.js +191 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/classes/comparator.js +143 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/classes/index.js +7 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/classes/range.js +557 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/classes/semver.js +333 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/functions/clean.js +8 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/functions/cmp.js +54 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/functions/coerce.js +62 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/functions/compare-build.js +9 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/functions/compare-loose.js +5 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/functions/compare.js +7 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/functions/diff.js +60 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/functions/eq.js +5 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/functions/gt.js +5 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/functions/gte.js +5 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/functions/inc.js +21 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/functions/lt.js +5 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/functions/lte.js +5 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/functions/major.js +5 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/functions/minor.js +5 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/functions/neq.js +5 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/functions/parse.js +18 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/functions/patch.js +5 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/functions/prerelease.js +8 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/functions/rcompare.js +5 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/functions/rsort.js +5 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/functions/satisfies.js +12 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/functions/sort.js +5 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/functions/valid.js +8 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/index.js +91 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/internal/constants.js +37 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/internal/debug.js +11 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/internal/identifiers.js +29 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/internal/lrucache.js +42 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/internal/parse-options.js +17 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/internal/re.js +223 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/package.json +78 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/preload.js +4 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/range.bnf +16 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/ranges/gtr.js +6 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/ranges/intersects.js +9 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/ranges/ltr.js +6 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/ranges/max-satisfying.js +27 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/ranges/min-satisfying.js +26 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/ranges/min-version.js +63 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/ranges/outside.js +82 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/ranges/simplify.js +49 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/ranges/subset.js +249 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/ranges/to-comparators.js +10 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/ranges/valid.js +13 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/sharp/LICENSE +191 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/sharp/README.md +118 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/sharp/install/build.js +38 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/sharp/install/check.js +14 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/sharp/lib/channel.js +177 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/sharp/lib/colour.js +195 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/sharp/lib/composite.js +212 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/sharp/lib/constructor.js +499 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/sharp/lib/index.d.ts +1971 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/sharp/lib/index.js +16 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/sharp/lib/input.js +809 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/sharp/lib/is.js +143 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/sharp/lib/libvips.js +207 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/sharp/lib/operation.js +1016 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/sharp/lib/output.js +1666 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/sharp/lib/resize.js +595 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/sharp/lib/sharp.js +121 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/sharp/lib/utility.js +291 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/sharp/package.json +202 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/sharp/src/binding.gyp +298 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/sharp/src/common.cc +1130 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/sharp/src/common.h +402 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/sharp/src/metadata.cc +346 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/sharp/src/metadata.h +90 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/sharp/src/operations.cc +499 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/sharp/src/operations.h +137 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/sharp/src/pipeline.cc +1814 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/sharp/src/pipeline.h +408 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/sharp/src/sharp.cc +43 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/sharp/src/stats.cc +186 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/sharp/src/stats.h +62 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/sharp/src/utilities.cc +288 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/sharp/src/utilities.h +22 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/package-lock.json +529 -0
- package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/package.json +5 -0
- package/skills/aipk_design/{auto_panel_splitter/scripts/auto_panel_splitter_bundle.js → update-requirements-from-design/scripts/split-design-boards-bundle.js} +10 -1
- package/skills/aipk_design/{auto_panel_splitter/scripts/panel_asset_mapper_bundle.js → update-requirements-from-design/scripts/sync-design-to-requirements-bundle.js} +10 -1
- package/skills/aipk_development/GURU_AI.md +1 -1
- package/skills/aipk_init_project/GURU_AI.md +2 -2
- package/skills/aipk_init_project/template/AGENTS_TEMPLATE.md +1 -1
- package/skills/aipk_operations/GURU_AI.md +1 -1
- package/skills/aipk_requirements/GURU_AI.md +2 -2
- package/skills/aipk_requirements/documentation/SKILL.md +23 -1
- package/skills/aipk_skill_generate/GURU_AI.md +1 -1
- package/skills/aipk_tool_prompts/GURU_AI.md +1 -1
- /package/skills/aipk_design/{auto_panel_splitter → update-requirements-from-design}/scripts/auto_panel_splitter.js +0 -0
- /package/skills/aipk_design/{auto_panel_splitter → update-requirements-from-design}/scripts/panel_asset_mapper.js +0 -0
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
# sharp
|
|
2
|
+
|
|
3
|
+
<img src="https://sharp.pixelplumbing.com/sharp-logo.svg" width="160" height="160" alt="sharp logo" align="right">
|
|
4
|
+
|
|
5
|
+
The typical use case for this high speed Node-API module
|
|
6
|
+
is to convert large images in common formats to
|
|
7
|
+
smaller, web-friendly JPEG, PNG, WebP, GIF and AVIF images of varying dimensions.
|
|
8
|
+
|
|
9
|
+
It can be used with all JavaScript runtimes
|
|
10
|
+
that provide support for Node-API v9, including
|
|
11
|
+
Node.js (^18.17.0 or >= 20.3.0), Deno and Bun.
|
|
12
|
+
|
|
13
|
+
Resizing an image is typically 4x-5x faster than using the
|
|
14
|
+
quickest ImageMagick and GraphicsMagick settings
|
|
15
|
+
due to its use of [libvips](https://github.com/libvips/libvips).
|
|
16
|
+
|
|
17
|
+
Colour spaces, embedded ICC profiles and alpha transparency channels are all handled correctly.
|
|
18
|
+
Lanczos resampling ensures quality is not sacrificed for speed.
|
|
19
|
+
|
|
20
|
+
As well as image resizing, operations such as
|
|
21
|
+
rotation, extraction, compositing and gamma correction are available.
|
|
22
|
+
|
|
23
|
+
Most modern macOS, Windows and Linux systems
|
|
24
|
+
do not require any additional install or runtime dependencies.
|
|
25
|
+
|
|
26
|
+
## Documentation
|
|
27
|
+
|
|
28
|
+
Visit [sharp.pixelplumbing.com](https://sharp.pixelplumbing.com/) for complete
|
|
29
|
+
[installation instructions](https://sharp.pixelplumbing.com/install),
|
|
30
|
+
[API documentation](https://sharp.pixelplumbing.com/api-constructor),
|
|
31
|
+
[benchmark tests](https://sharp.pixelplumbing.com/performance) and
|
|
32
|
+
[changelog](https://sharp.pixelplumbing.com/changelog).
|
|
33
|
+
|
|
34
|
+
## Examples
|
|
35
|
+
|
|
36
|
+
```sh
|
|
37
|
+
npm install sharp
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
```javascript
|
|
41
|
+
const sharp = require('sharp');
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Callback
|
|
45
|
+
|
|
46
|
+
```javascript
|
|
47
|
+
sharp(inputBuffer)
|
|
48
|
+
.resize(320, 240)
|
|
49
|
+
.toFile('output.webp', (err, info) => { ... });
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Promise
|
|
53
|
+
|
|
54
|
+
```javascript
|
|
55
|
+
sharp('input.jpg')
|
|
56
|
+
.rotate()
|
|
57
|
+
.resize(200)
|
|
58
|
+
.jpeg({ mozjpeg: true })
|
|
59
|
+
.toBuffer()
|
|
60
|
+
.then( data => { ... })
|
|
61
|
+
.catch( err => { ... });
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Async/await
|
|
65
|
+
|
|
66
|
+
```javascript
|
|
67
|
+
const semiTransparentRedPng = await sharp({
|
|
68
|
+
create: {
|
|
69
|
+
width: 48,
|
|
70
|
+
height: 48,
|
|
71
|
+
channels: 4,
|
|
72
|
+
background: { r: 255, g: 0, b: 0, alpha: 0.5 }
|
|
73
|
+
}
|
|
74
|
+
})
|
|
75
|
+
.png()
|
|
76
|
+
.toBuffer();
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Stream
|
|
80
|
+
|
|
81
|
+
```javascript
|
|
82
|
+
const roundedCorners = Buffer.from(
|
|
83
|
+
'<svg><rect x="0" y="0" width="200" height="200" rx="50" ry="50"/></svg>'
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
const roundedCornerResizer =
|
|
87
|
+
sharp()
|
|
88
|
+
.resize(200, 200)
|
|
89
|
+
.composite([{
|
|
90
|
+
input: roundedCorners,
|
|
91
|
+
blend: 'dest-in'
|
|
92
|
+
}])
|
|
93
|
+
.png();
|
|
94
|
+
|
|
95
|
+
readableStream
|
|
96
|
+
.pipe(roundedCornerResizer)
|
|
97
|
+
.pipe(writableStream);
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## Contributing
|
|
101
|
+
|
|
102
|
+
A [guide for contributors](https://github.com/lovell/sharp/blob/main/.github/CONTRIBUTING.md)
|
|
103
|
+
covers reporting bugs, requesting features and submitting code changes.
|
|
104
|
+
|
|
105
|
+
## Licensing
|
|
106
|
+
|
|
107
|
+
Copyright 2013 Lovell Fuller and others.
|
|
108
|
+
|
|
109
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
110
|
+
you may not use this file except in compliance with the License.
|
|
111
|
+
You may obtain a copy of the License at
|
|
112
|
+
[https://www.apache.org/licenses/LICENSE-2.0](https://www.apache.org/licenses/LICENSE-2.0)
|
|
113
|
+
|
|
114
|
+
Unless required by applicable law or agreed to in writing, software
|
|
115
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
116
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
117
|
+
See the License for the specific language governing permissions and
|
|
118
|
+
limitations under the License.
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
Copyright 2013 Lovell Fuller and others.
|
|
3
|
+
SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
const {
|
|
7
|
+
useGlobalLibvips,
|
|
8
|
+
globalLibvipsVersion,
|
|
9
|
+
log,
|
|
10
|
+
spawnRebuild,
|
|
11
|
+
} = require('../lib/libvips');
|
|
12
|
+
|
|
13
|
+
log('Attempting to build from source via node-gyp');
|
|
14
|
+
log('See https://sharp.pixelplumbing.com/install#building-from-source');
|
|
15
|
+
|
|
16
|
+
try {
|
|
17
|
+
const addonApi = require('node-addon-api');
|
|
18
|
+
log(`Found node-addon-api ${addonApi.version || ''}`);
|
|
19
|
+
} catch (_err) {
|
|
20
|
+
log('Please add node-addon-api to your dependencies');
|
|
21
|
+
process.exit(1);
|
|
22
|
+
}
|
|
23
|
+
try {
|
|
24
|
+
const gyp = require('node-gyp');
|
|
25
|
+
log(`Found node-gyp ${gyp().version}`);
|
|
26
|
+
} catch (_err) {
|
|
27
|
+
log('Please add node-gyp to your dependencies');
|
|
28
|
+
process.exit(1);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (useGlobalLibvips(log)) {
|
|
32
|
+
log(`Detected globally-installed libvips v${globalLibvipsVersion()}`);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const status = spawnRebuild();
|
|
36
|
+
if (status !== 0) {
|
|
37
|
+
process.exit(status);
|
|
38
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
Copyright 2013 Lovell Fuller and others.
|
|
3
|
+
SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
try {
|
|
7
|
+
const { useGlobalLibvips } = require('../lib/libvips');
|
|
8
|
+
if (useGlobalLibvips() || process.env.npm_config_build_from_source) {
|
|
9
|
+
process.exit(1);
|
|
10
|
+
}
|
|
11
|
+
} catch (err) {
|
|
12
|
+
const summary = err.message.split(/\n/).slice(0, 1);
|
|
13
|
+
console.log(`sharp: skipping install check: ${summary}`);
|
|
14
|
+
}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
Copyright 2013 Lovell Fuller and others.
|
|
3
|
+
SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
const is = require('./is');
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Boolean operations for bandbool.
|
|
10
|
+
* @private
|
|
11
|
+
*/
|
|
12
|
+
const bool = {
|
|
13
|
+
and: 'and',
|
|
14
|
+
or: 'or',
|
|
15
|
+
eor: 'eor'
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Remove alpha channels, if any. This is a no-op if the image does not have an alpha channel.
|
|
20
|
+
*
|
|
21
|
+
* See also {@link /api-operation/#flatten flatten}.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* sharp('rgba.png')
|
|
25
|
+
* .removeAlpha()
|
|
26
|
+
* .toFile('rgb.png', function(err, info) {
|
|
27
|
+
* // rgb.png is a 3 channel image without an alpha channel
|
|
28
|
+
* });
|
|
29
|
+
*
|
|
30
|
+
* @returns {Sharp}
|
|
31
|
+
*/
|
|
32
|
+
function removeAlpha () {
|
|
33
|
+
this.options.removeAlpha = true;
|
|
34
|
+
return this;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Ensure the output image has an alpha transparency channel.
|
|
39
|
+
* If missing, the added alpha channel will have the specified
|
|
40
|
+
* transparency level, defaulting to fully-opaque (1).
|
|
41
|
+
* This is a no-op if the image already has an alpha channel.
|
|
42
|
+
*
|
|
43
|
+
* @since 0.21.2
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* // rgba.png will be a 4 channel image with a fully-opaque alpha channel
|
|
47
|
+
* await sharp('rgb.jpg')
|
|
48
|
+
* .ensureAlpha()
|
|
49
|
+
* .toFile('rgba.png')
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* // rgba is a 4 channel image with a fully-transparent alpha channel
|
|
53
|
+
* const rgba = await sharp(rgb)
|
|
54
|
+
* .ensureAlpha(0)
|
|
55
|
+
* .toBuffer();
|
|
56
|
+
*
|
|
57
|
+
* @param {number} [alpha=1] - alpha transparency level (0=fully-transparent, 1=fully-opaque)
|
|
58
|
+
* @returns {Sharp}
|
|
59
|
+
* @throws {Error} Invalid alpha transparency level
|
|
60
|
+
*/
|
|
61
|
+
function ensureAlpha (alpha) {
|
|
62
|
+
if (is.defined(alpha)) {
|
|
63
|
+
if (is.number(alpha) && is.inRange(alpha, 0, 1)) {
|
|
64
|
+
this.options.ensureAlpha = alpha;
|
|
65
|
+
} else {
|
|
66
|
+
throw is.invalidParameterError('alpha', 'number between 0 and 1', alpha);
|
|
67
|
+
}
|
|
68
|
+
} else {
|
|
69
|
+
this.options.ensureAlpha = 1;
|
|
70
|
+
}
|
|
71
|
+
return this;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Extract a single channel from a multi-channel image.
|
|
76
|
+
*
|
|
77
|
+
* The output colourspace will be either `b-w` (8-bit) or `grey16` (16-bit).
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* // green.jpg is a greyscale image containing the green channel of the input
|
|
81
|
+
* await sharp(input)
|
|
82
|
+
* .extractChannel('green')
|
|
83
|
+
* .toFile('green.jpg');
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* // red1 is the red value of the first pixel, red2 the second pixel etc.
|
|
87
|
+
* const [red1, red2, ...] = await sharp(input)
|
|
88
|
+
* .extractChannel(0)
|
|
89
|
+
* .raw()
|
|
90
|
+
* .toBuffer();
|
|
91
|
+
*
|
|
92
|
+
* @param {number|string} channel - zero-indexed channel/band number to extract, or `red`, `green`, `blue` or `alpha`.
|
|
93
|
+
* @returns {Sharp}
|
|
94
|
+
* @throws {Error} Invalid channel
|
|
95
|
+
*/
|
|
96
|
+
function extractChannel (channel) {
|
|
97
|
+
const channelMap = { red: 0, green: 1, blue: 2, alpha: 3 };
|
|
98
|
+
if (Object.keys(channelMap).includes(channel)) {
|
|
99
|
+
channel = channelMap[channel];
|
|
100
|
+
}
|
|
101
|
+
if (is.integer(channel) && is.inRange(channel, 0, 4)) {
|
|
102
|
+
this.options.extractChannel = channel;
|
|
103
|
+
} else {
|
|
104
|
+
throw is.invalidParameterError('channel', 'integer or one of: red, green, blue, alpha', channel);
|
|
105
|
+
}
|
|
106
|
+
return this;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Join one or more channels to the image.
|
|
111
|
+
* The meaning of the added channels depends on the output colourspace, set with `toColourspace()`.
|
|
112
|
+
* By default the output image will be web-friendly sRGB, with additional channels interpreted as alpha channels.
|
|
113
|
+
* Channel ordering follows vips convention:
|
|
114
|
+
* - sRGB: 0: Red, 1: Green, 2: Blue, 3: Alpha.
|
|
115
|
+
* - CMYK: 0: Magenta, 1: Cyan, 2: Yellow, 3: Black, 4: Alpha.
|
|
116
|
+
*
|
|
117
|
+
* Buffers may be any of the image formats supported by sharp.
|
|
118
|
+
* For raw pixel input, the `options` object should contain a `raw` attribute, which follows the format of the attribute of the same name in the `sharp()` constructor.
|
|
119
|
+
*
|
|
120
|
+
* @param {Array<string|Buffer>|string|Buffer} images - one or more images (file paths, Buffers).
|
|
121
|
+
* @param {Object} options - image options, see `sharp()` constructor.
|
|
122
|
+
* @returns {Sharp}
|
|
123
|
+
* @throws {Error} Invalid parameters
|
|
124
|
+
*/
|
|
125
|
+
function joinChannel (images, options) {
|
|
126
|
+
if (Array.isArray(images)) {
|
|
127
|
+
images.forEach(function (image) {
|
|
128
|
+
this.options.joinChannelIn.push(this._createInputDescriptor(image, options));
|
|
129
|
+
}, this);
|
|
130
|
+
} else {
|
|
131
|
+
this.options.joinChannelIn.push(this._createInputDescriptor(images, options));
|
|
132
|
+
}
|
|
133
|
+
return this;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Perform a bitwise boolean operation on all input image channels (bands) to produce a single channel output image.
|
|
138
|
+
*
|
|
139
|
+
* @example
|
|
140
|
+
* sharp('3-channel-rgb-input.png')
|
|
141
|
+
* .bandbool(sharp.bool.and)
|
|
142
|
+
* .toFile('1-channel-output.png', function (err, info) {
|
|
143
|
+
* // The output will be a single channel image where each pixel `P = R & G & B`.
|
|
144
|
+
* // If `I(1,1) = [247, 170, 14] = [0b11110111, 0b10101010, 0b00001111]`
|
|
145
|
+
* // then `O(1,1) = 0b11110111 & 0b10101010 & 0b00001111 = 0b00000010 = 2`.
|
|
146
|
+
* });
|
|
147
|
+
*
|
|
148
|
+
* @param {string} boolOp - one of `and`, `or` or `eor` to perform that bitwise operation, like the C logic operators `&`, `|` and `^` respectively.
|
|
149
|
+
* @returns {Sharp}
|
|
150
|
+
* @throws {Error} Invalid parameters
|
|
151
|
+
*/
|
|
152
|
+
function bandbool (boolOp) {
|
|
153
|
+
if (is.string(boolOp) && is.inArray(boolOp, ['and', 'or', 'eor'])) {
|
|
154
|
+
this.options.bandBoolOp = boolOp;
|
|
155
|
+
} else {
|
|
156
|
+
throw is.invalidParameterError('boolOp', 'one of: and, or, eor', boolOp);
|
|
157
|
+
}
|
|
158
|
+
return this;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Decorate the Sharp prototype with channel-related functions.
|
|
163
|
+
* @module Sharp
|
|
164
|
+
* @private
|
|
165
|
+
*/
|
|
166
|
+
module.exports = (Sharp) => {
|
|
167
|
+
Object.assign(Sharp.prototype, {
|
|
168
|
+
// Public instance functions
|
|
169
|
+
removeAlpha,
|
|
170
|
+
ensureAlpha,
|
|
171
|
+
extractChannel,
|
|
172
|
+
joinChannel,
|
|
173
|
+
bandbool
|
|
174
|
+
});
|
|
175
|
+
// Class attributes
|
|
176
|
+
Sharp.bool = bool;
|
|
177
|
+
};
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
Copyright 2013 Lovell Fuller and others.
|
|
3
|
+
SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
const color = require('@img/colour');
|
|
7
|
+
const is = require('./is');
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Colourspaces.
|
|
11
|
+
* @private
|
|
12
|
+
*/
|
|
13
|
+
const colourspace = {
|
|
14
|
+
multiband: 'multiband',
|
|
15
|
+
'b-w': 'b-w',
|
|
16
|
+
bw: 'b-w',
|
|
17
|
+
cmyk: 'cmyk',
|
|
18
|
+
srgb: 'srgb'
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Tint the image using the provided colour.
|
|
23
|
+
* An alpha channel may be present and will be unchanged by the operation.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* const output = await sharp(input)
|
|
27
|
+
* .tint({ r: 255, g: 240, b: 16 })
|
|
28
|
+
* .toBuffer();
|
|
29
|
+
*
|
|
30
|
+
* @param {string|Object} tint - Parsed by the [color](https://www.npmjs.org/package/color) module.
|
|
31
|
+
* @returns {Sharp}
|
|
32
|
+
* @throws {Error} Invalid parameter
|
|
33
|
+
*/
|
|
34
|
+
function tint (tint) {
|
|
35
|
+
this._setBackgroundColourOption('tint', tint);
|
|
36
|
+
return this;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Convert to 8-bit greyscale; 256 shades of grey.
|
|
41
|
+
* This is a linear operation. If the input image is in a non-linear colour space such as sRGB, use `gamma()` with `greyscale()` for the best results.
|
|
42
|
+
* By default the output image will be web-friendly sRGB and contain three (identical) colour channels.
|
|
43
|
+
* This may be overridden by other sharp operations such as `toColourspace('b-w')`,
|
|
44
|
+
* which will produce an output image containing one colour channel.
|
|
45
|
+
* An alpha channel may be present, and will be unchanged by the operation.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* const output = await sharp(input).greyscale().toBuffer();
|
|
49
|
+
*
|
|
50
|
+
* @param {Boolean} [greyscale=true]
|
|
51
|
+
* @returns {Sharp}
|
|
52
|
+
*/
|
|
53
|
+
function greyscale (greyscale) {
|
|
54
|
+
this.options.greyscale = is.bool(greyscale) ? greyscale : true;
|
|
55
|
+
return this;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Alternative spelling of `greyscale`.
|
|
60
|
+
* @param {Boolean} [grayscale=true]
|
|
61
|
+
* @returns {Sharp}
|
|
62
|
+
*/
|
|
63
|
+
function grayscale (grayscale) {
|
|
64
|
+
return this.greyscale(grayscale);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Set the pipeline colourspace.
|
|
69
|
+
*
|
|
70
|
+
* The input image will be converted to the provided colourspace at the start of the pipeline.
|
|
71
|
+
* All operations will use this colourspace before converting to the output colourspace,
|
|
72
|
+
* as defined by {@link #tocolourspace toColourspace}.
|
|
73
|
+
*
|
|
74
|
+
* @since 0.29.0
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* // Run pipeline in 16 bits per channel RGB while converting final result to 8 bits per channel sRGB.
|
|
78
|
+
* await sharp(input)
|
|
79
|
+
* .pipelineColourspace('rgb16')
|
|
80
|
+
* .toColourspace('srgb')
|
|
81
|
+
* .toFile('16bpc-pipeline-to-8bpc-output.png')
|
|
82
|
+
*
|
|
83
|
+
* @param {string} [colourspace] - pipeline colourspace e.g. `rgb16`, `scrgb`, `lab`, `grey16` [...](https://www.libvips.org/API/current/enum.Interpretation.html)
|
|
84
|
+
* @returns {Sharp}
|
|
85
|
+
* @throws {Error} Invalid parameters
|
|
86
|
+
*/
|
|
87
|
+
function pipelineColourspace (colourspace) {
|
|
88
|
+
if (!is.string(colourspace)) {
|
|
89
|
+
throw is.invalidParameterError('colourspace', 'string', colourspace);
|
|
90
|
+
}
|
|
91
|
+
this.options.colourspacePipeline = colourspace;
|
|
92
|
+
return this;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Alternative spelling of `pipelineColourspace`.
|
|
97
|
+
* @param {string} [colorspace] - pipeline colorspace.
|
|
98
|
+
* @returns {Sharp}
|
|
99
|
+
* @throws {Error} Invalid parameters
|
|
100
|
+
*/
|
|
101
|
+
function pipelineColorspace (colorspace) {
|
|
102
|
+
return this.pipelineColourspace(colorspace);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Set the output colourspace.
|
|
107
|
+
* By default output image will be web-friendly sRGB, with additional channels interpreted as alpha channels.
|
|
108
|
+
*
|
|
109
|
+
* @example
|
|
110
|
+
* // Output 16 bits per pixel RGB
|
|
111
|
+
* await sharp(input)
|
|
112
|
+
* .toColourspace('rgb16')
|
|
113
|
+
* .toFile('16-bpp.png')
|
|
114
|
+
*
|
|
115
|
+
* @param {string} [colourspace] - output colourspace e.g. `srgb`, `rgb`, `cmyk`, `lab`, `b-w` [...](https://www.libvips.org/API/current/enum.Interpretation.html)
|
|
116
|
+
* @returns {Sharp}
|
|
117
|
+
* @throws {Error} Invalid parameters
|
|
118
|
+
*/
|
|
119
|
+
function toColourspace (colourspace) {
|
|
120
|
+
if (!is.string(colourspace)) {
|
|
121
|
+
throw is.invalidParameterError('colourspace', 'string', colourspace);
|
|
122
|
+
}
|
|
123
|
+
this.options.colourspace = colourspace;
|
|
124
|
+
return this;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Alternative spelling of `toColourspace`.
|
|
129
|
+
* @param {string} [colorspace] - output colorspace.
|
|
130
|
+
* @returns {Sharp}
|
|
131
|
+
* @throws {Error} Invalid parameters
|
|
132
|
+
*/
|
|
133
|
+
function toColorspace (colorspace) {
|
|
134
|
+
return this.toColourspace(colorspace);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Create a RGBA colour array from a given value.
|
|
139
|
+
* @private
|
|
140
|
+
* @param {string|Object} value
|
|
141
|
+
* @throws {Error} Invalid value
|
|
142
|
+
*/
|
|
143
|
+
function _getBackgroundColourOption (value) {
|
|
144
|
+
if (
|
|
145
|
+
is.object(value) ||
|
|
146
|
+
(is.string(value) && value.length >= 3 && value.length <= 200)
|
|
147
|
+
) {
|
|
148
|
+
const colour = color(value);
|
|
149
|
+
return [
|
|
150
|
+
colour.red(),
|
|
151
|
+
colour.green(),
|
|
152
|
+
colour.blue(),
|
|
153
|
+
Math.round(colour.alpha() * 255)
|
|
154
|
+
];
|
|
155
|
+
} else {
|
|
156
|
+
throw is.invalidParameterError('background', 'object or string', value);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Update a colour attribute of the this.options Object.
|
|
162
|
+
* @private
|
|
163
|
+
* @param {string} key
|
|
164
|
+
* @param {string|Object} value
|
|
165
|
+
* @throws {Error} Invalid value
|
|
166
|
+
*/
|
|
167
|
+
function _setBackgroundColourOption (key, value) {
|
|
168
|
+
if (is.defined(value)) {
|
|
169
|
+
this.options[key] = _getBackgroundColourOption(value);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Decorate the Sharp prototype with colour-related functions.
|
|
175
|
+
* @module Sharp
|
|
176
|
+
* @private
|
|
177
|
+
*/
|
|
178
|
+
module.exports = (Sharp) => {
|
|
179
|
+
Object.assign(Sharp.prototype, {
|
|
180
|
+
// Public
|
|
181
|
+
tint,
|
|
182
|
+
greyscale,
|
|
183
|
+
grayscale,
|
|
184
|
+
pipelineColourspace,
|
|
185
|
+
pipelineColorspace,
|
|
186
|
+
toColourspace,
|
|
187
|
+
toColorspace,
|
|
188
|
+
// Private
|
|
189
|
+
_getBackgroundColourOption,
|
|
190
|
+
_setBackgroundColourOption
|
|
191
|
+
});
|
|
192
|
+
// Class attributes
|
|
193
|
+
Sharp.colourspace = colourspace;
|
|
194
|
+
Sharp.colorspace = colourspace;
|
|
195
|
+
};
|