sharp 0.32.6 → 0.33.0-alpha.11
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/README.md +6 -2
- package/install/check.js +36 -0
- package/lib/constructor.js +6 -5
- package/lib/index.d.ts +13 -16
- package/lib/input.js +34 -8
- package/lib/is.js +28 -14
- package/lib/libvips.js +86 -55
- package/lib/output.js +41 -24
- package/lib/resize.js +46 -46
- package/lib/sharp.js +71 -26
- package/lib/utility.js +25 -25
- package/package.json +56 -41
- package/{binding.gyp → src/binding.gyp} +89 -43
- package/src/common.cc +5 -4
- package/src/common.h +6 -5
- package/src/metadata.cc +5 -5
- package/src/operations.cc +5 -2
- package/src/operations.h +1 -1
- package/src/pipeline.cc +19 -19
- package/src/pipeline.h +5 -1
- package/src/sharp.cc +6 -7
- package/src/stats.cc +5 -5
- package/src/utilities.cc +20 -5
- package/install/can-compile.js +0 -14
- package/install/dll-copy.js +0 -40
- package/install/libvips.js +0 -222
- package/lib/agent.js +0 -44
- package/lib/platform.js +0 -30
- package/src/libvips/cplusplus/VConnection.cpp +0 -151
- package/src/libvips/cplusplus/VError.cpp +0 -49
- package/src/libvips/cplusplus/VImage.cpp +0 -1548
- package/src/libvips/cplusplus/VInterpolate.cpp +0 -62
- package/src/libvips/cplusplus/VRegion.cpp +0 -27
- package/src/libvips/cplusplus/vips-operators.cpp +0 -3760
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sharp",
|
|
3
3
|
"description": "High performance Node.js image processing, the fastest module to resize JPEG, PNG, WebP, GIF, AVIF and TIFF images",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.33.0-alpha.11",
|
|
5
5
|
"author": "Lovell Fuller <npm@lovell.info>",
|
|
6
6
|
"homepage": "https://github.com/lovell/sharp",
|
|
7
7
|
"contributors": [
|
|
@@ -86,32 +86,36 @@
|
|
|
86
86
|
"Ankur Parihar <ankur.github@gmail.com>",
|
|
87
87
|
"Brahim Ait elhaj <brahima@gmail.com>",
|
|
88
88
|
"Mart Jansink <m.jansink@gmail.com>",
|
|
89
|
-
"Lachlan Newman <lachnewman007@gmail.com>"
|
|
89
|
+
"Lachlan Newman <lachnewman007@gmail.com>",
|
|
90
|
+
"Dennis Beatty <dennis@dcbeatty.com>",
|
|
91
|
+
"Ingvar Stepanyan <me@rreverser.com>"
|
|
90
92
|
],
|
|
91
93
|
"scripts": {
|
|
92
|
-
"install": "
|
|
93
|
-
"clean": "rm -rf
|
|
94
|
+
"install": "node install/check",
|
|
95
|
+
"clean": "rm -rf src/build/ .nyc_output/ coverage/ test/fixtures/output.*",
|
|
94
96
|
"test": "npm run test-lint && npm run test-unit && npm run test-licensing && npm run test-types",
|
|
95
97
|
"test-lint": "semistandard && cpplint",
|
|
96
98
|
"test-unit": "nyc --reporter=lcov --reporter=text --check-coverage --branches=100 mocha",
|
|
97
|
-
"test-licensing": "license-checker --production --summary --onlyAllow=\"Apache-2.0;BSD;ISC;MIT\"",
|
|
99
|
+
"test-licensing": "license-checker --production --summary --onlyAllow=\"Apache-2.0;BSD;ISC;LGPL-3.0-or-later;MIT\"",
|
|
98
100
|
"test-leak": "./test/leak/leak.sh",
|
|
99
101
|
"test-types": "tsd",
|
|
102
|
+
"package-from-local-build": "node npm/from-local-build",
|
|
103
|
+
"package-from-github-release": "node npm/from-github-release",
|
|
100
104
|
"docs-build": "node docs/build && node docs/search-index/build",
|
|
101
105
|
"docs-serve": "cd docs && npx serve",
|
|
102
106
|
"docs-publish": "cd docs && npx firebase-tools deploy --project pixelplumbing --only hosting:pixelplumbing-sharp"
|
|
103
107
|
},
|
|
108
|
+
"type": "commonjs",
|
|
104
109
|
"main": "lib/index.js",
|
|
105
110
|
"types": "lib/index.d.ts",
|
|
106
111
|
"files": [
|
|
107
|
-
"
|
|
108
|
-
"
|
|
109
|
-
"
|
|
110
|
-
"src/**"
|
|
112
|
+
"install",
|
|
113
|
+
"lib",
|
|
114
|
+
"src/*.{cc,h,gyp}"
|
|
111
115
|
],
|
|
112
116
|
"repository": {
|
|
113
117
|
"type": "git",
|
|
114
|
-
"url": "git://github.com/lovell/sharp"
|
|
118
|
+
"url": "git://github.com/lovell/sharp.git"
|
|
115
119
|
},
|
|
116
120
|
"keywords": [
|
|
117
121
|
"jpeg",
|
|
@@ -134,57 +138,63 @@
|
|
|
134
138
|
"dependencies": {
|
|
135
139
|
"color": "^4.2.3",
|
|
136
140
|
"detect-libc": "^2.0.2",
|
|
137
|
-
"
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
"
|
|
141
|
-
"
|
|
142
|
-
"
|
|
141
|
+
"semver": "^7.5.4"
|
|
142
|
+
},
|
|
143
|
+
"optionalDependencies": {
|
|
144
|
+
"@img/sharp-darwin-arm64": "0.33.0-alpha.11",
|
|
145
|
+
"@img/sharp-darwin-x64": "0.33.0-alpha.11",
|
|
146
|
+
"@img/sharp-libvips-darwin-arm64": "0.0.3",
|
|
147
|
+
"@img/sharp-libvips-darwin-x64": "0.0.3",
|
|
148
|
+
"@img/sharp-libvips-linux-arm": "0.0.3",
|
|
149
|
+
"@img/sharp-libvips-linux-arm64": "0.0.3",
|
|
150
|
+
"@img/sharp-libvips-linux-s390x": "0.0.3",
|
|
151
|
+
"@img/sharp-libvips-linux-x64": "0.0.3",
|
|
152
|
+
"@img/sharp-libvips-linuxmusl-arm64": "0.0.3",
|
|
153
|
+
"@img/sharp-libvips-linuxmusl-x64": "0.0.3",
|
|
154
|
+
"@img/sharp-linux-arm": "0.33.0-alpha.11",
|
|
155
|
+
"@img/sharp-linux-arm64": "0.33.0-alpha.11",
|
|
156
|
+
"@img/sharp-linux-s390x": "0.33.0-alpha.11",
|
|
157
|
+
"@img/sharp-linux-x64": "0.33.0-alpha.11",
|
|
158
|
+
"@img/sharp-linuxmusl-arm64": "0.33.0-alpha.11",
|
|
159
|
+
"@img/sharp-linuxmusl-x64": "0.33.0-alpha.11",
|
|
160
|
+
"@img/sharp-wasm32": "0.33.0-alpha.11",
|
|
161
|
+
"@img/sharp-win32-ia32": "0.33.0-alpha.11",
|
|
162
|
+
"@img/sharp-win32-x64": "0.33.0-alpha.11"
|
|
143
163
|
},
|
|
144
164
|
"devDependencies": {
|
|
165
|
+
"@emnapi/runtime": "^0.43.1",
|
|
166
|
+
"@img/sharp-libvips-dev": "0.0.3",
|
|
167
|
+
"@img/sharp-libvips-dev-wasm32": "0.0.3",
|
|
168
|
+
"@img/sharp-libvips-win32-ia32": "0.0.3",
|
|
169
|
+
"@img/sharp-libvips-win32-x64": "0.0.3",
|
|
145
170
|
"@types/node": "*",
|
|
146
|
-
"async": "^3.2.
|
|
171
|
+
"async": "^3.2.5",
|
|
147
172
|
"cc": "^3.0.1",
|
|
148
|
-
"
|
|
173
|
+
"emnapi": "^0.43.1",
|
|
174
|
+
"exif-reader": "^2.0.0",
|
|
149
175
|
"extract-zip": "^2.0.1",
|
|
150
176
|
"icc": "^3.0.0",
|
|
151
177
|
"jsdoc-to-markdown": "^8.0.0",
|
|
152
178
|
"license-checker": "^25.0.1",
|
|
153
179
|
"mocha": "^10.2.0",
|
|
154
|
-
"
|
|
180
|
+
"node-addon-api": "^7.0.0",
|
|
155
181
|
"nyc": "^15.1.0",
|
|
156
|
-
"prebuild": "^12.
|
|
157
|
-
"semistandard": "^
|
|
182
|
+
"prebuild": "^12.1.0",
|
|
183
|
+
"semistandard": "^17.0.0",
|
|
184
|
+
"tar-fs": "^3.0.4",
|
|
158
185
|
"tsd": "^0.29.0"
|
|
159
186
|
},
|
|
160
187
|
"license": "Apache-2.0",
|
|
161
|
-
"config": {
|
|
162
|
-
"libvips": "8.14.5",
|
|
163
|
-
"integrity": {
|
|
164
|
-
"darwin-arm64v8": "sha512-1QZzICfCJd4wAO0P6qmYI5e5VFMt9iCE4QgefI8VMMbdSzjIXA9L/ARN6pkMQPZ3h20Y9RtJ2W1skgCsvCIccw==",
|
|
165
|
-
"darwin-x64": "sha512-sMIKMYXsdU9FlIfztj6Kt/SfHlhlDpP0Ups7ftVFqwjaszmYmpI9y/d/q3mLb4jrzuSiSUEislSWCwBnW7MPTw==",
|
|
166
|
-
"linux-arm64v8": "sha512-CD8owELzkDumaom+O3jJ8fKamILAQdj+//KK/VNcHK3sngUcFpdjx36C8okwbux9sml/T7GTB/gzpvReDrAejQ==",
|
|
167
|
-
"linux-armv6": "sha512-wk6IPHatDFVWKJy7lI1TJezHGHPQut1wF2bwx256KlZwXUQU3fcVcMpV1zxXjgLFewHq2+uhyMkoSGBPahWzlA==",
|
|
168
|
-
"linux-armv7": "sha512-HEZC9KYtkmBK5rUR2MqBhrVarnQVZ/TwLUeLkKq0XuoM2pc/eXI6N0Fh5NGEFwdXI2XE8g1ySf+OYS6DDi+xCQ==",
|
|
169
|
-
"linux-x64": "sha512-SlFWrITSW5XVUkaFPQOySAaSGXnhkGJCj8X2wGYYta9hk5piZldQyMp4zwy0z6UeRu1qKTKtZvmq28W3Gnh9xA==",
|
|
170
|
-
"linuxmusl-arm64v8": "sha512-ga9iX7WUva3sG/VsKkOD318InLlCfPIztvzCZKZ2/+izQXRbQi8VoXWMHgEN4KHACv45FTl7mJ/8CRqUzhS8wQ==",
|
|
171
|
-
"linuxmusl-x64": "sha512-yeaHnpfee1hrZLok2l4eFceHzlfq8gN3QOu0R4Mh8iMK5O5vAUu97bdtxeZZeJJvHw8tfh2/msGi0qysxKN8bw==",
|
|
172
|
-
"win32-arm64v8": "sha512-kR91hy9w1+GEXK56hLh51+hBCBo7T+ijM4Slkmvb/2PsYZySq5H7s61n99iDYl6kTJP2y9sW5Xcvm3uuXDaDgg==",
|
|
173
|
-
"win32-ia32": "sha512-HrnofEbzHNpHJ0vVnjsTj5yfgVdcqdWshXuwFO2zc8xlEjA83BvXZ0lVj9MxPxkxJ2ta+/UlLr+CFzc5bOceMw==",
|
|
174
|
-
"win32-x64": "sha512-BwKckinJZ0Fu/EcunqiLPwOLEBWp4xf8GV7nvmVuKKz5f6B+GxoA2k9aa2wueqv4r4RJVgV/aWXZWFKOIjre/Q=="
|
|
175
|
-
},
|
|
176
|
-
"runtime": "napi",
|
|
177
|
-
"target": 7
|
|
178
|
-
},
|
|
179
188
|
"engines": {
|
|
180
|
-
"node": ">=
|
|
189
|
+
"node": "^18.17.0 || ^20.3.0 || >=21.0.0",
|
|
190
|
+
"libvips": ">=8.15.0"
|
|
181
191
|
},
|
|
182
192
|
"funding": {
|
|
183
193
|
"url": "https://opencollective.com/libvips"
|
|
184
194
|
},
|
|
185
195
|
"binary": {
|
|
186
196
|
"napi_versions": [
|
|
187
|
-
|
|
197
|
+
9
|
|
188
198
|
]
|
|
189
199
|
},
|
|
190
200
|
"semistandard": {
|
|
@@ -198,6 +208,11 @@
|
|
|
198
208
|
"build/include"
|
|
199
209
|
]
|
|
200
210
|
},
|
|
211
|
+
"nyc": {
|
|
212
|
+
"include": [
|
|
213
|
+
"lib"
|
|
214
|
+
]
|
|
215
|
+
},
|
|
201
216
|
"tsd": {
|
|
202
217
|
"directory": "test/types/"
|
|
203
218
|
}
|
|
@@ -1,8 +1,14 @@
|
|
|
1
|
+
# Copyright 2013 Lovell Fuller and others.
|
|
2
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
1
4
|
{
|
|
2
5
|
'variables': {
|
|
3
|
-
'vips_version': '<!(node -p "require(\'
|
|
4
|
-
'platform_and_arch': '<!(node -p "require(\'
|
|
5
|
-
'
|
|
6
|
+
'vips_version': '<!(node -p "require(\'../lib/libvips\').minimumLibvipsVersion")',
|
|
7
|
+
'platform_and_arch': '<!(node -p "require(\'../lib/libvips\').buildPlatformArch()")',
|
|
8
|
+
'sharp_libvips_version': '<!(node -p "require(\'../package.json\').optionalDependencies[\'@img/sharp-libvips-<(platform_and_arch)\']")',
|
|
9
|
+
'sharp_libvips_include_dir': '<!(node -p "require(\'../lib/libvips\').buildSharpLibvipsIncludeDir()")',
|
|
10
|
+
'sharp_libvips_cplusplus_dir': '<!(node -p "require(\'../lib/libvips\').buildSharpLibvipsCPlusPlusDir()")',
|
|
11
|
+
'sharp_libvips_lib_dir': '<!(node -p "require(\'../lib/libvips\').buildSharpLibvipsLibDir()")'
|
|
6
12
|
},
|
|
7
13
|
'targets': [{
|
|
8
14
|
'target_name': 'libvips-cpp',
|
|
@@ -15,23 +21,23 @@
|
|
|
15
21
|
'_ALLOW_KEYWORD_MACROS'
|
|
16
22
|
],
|
|
17
23
|
'sources': [
|
|
18
|
-
'
|
|
19
|
-
'
|
|
20
|
-
'
|
|
21
|
-
'
|
|
22
|
-
'
|
|
24
|
+
'<(sharp_libvips_cplusplus_dir)/VConnection.cpp',
|
|
25
|
+
'<(sharp_libvips_cplusplus_dir)/VError.cpp',
|
|
26
|
+
'<(sharp_libvips_cplusplus_dir)/VImage.cpp',
|
|
27
|
+
'<(sharp_libvips_cplusplus_dir)/VInterpolate.cpp',
|
|
28
|
+
'<(sharp_libvips_cplusplus_dir)/VRegion.cpp'
|
|
23
29
|
],
|
|
24
30
|
'include_dirs': [
|
|
25
|
-
'<(
|
|
26
|
-
'<(
|
|
27
|
-
'<(
|
|
31
|
+
'<(sharp_libvips_include_dir)',
|
|
32
|
+
'<(sharp_libvips_include_dir)/glib-2.0',
|
|
33
|
+
'<(sharp_libvips_lib_dir)/glib-2.0/include'
|
|
28
34
|
],
|
|
29
35
|
'link_settings': {
|
|
30
|
-
'library_dirs': [
|
|
36
|
+
'library_dirs': [
|
|
37
|
+
'<(sharp_libvips_lib_dir)'
|
|
38
|
+
],
|
|
31
39
|
'libraries': [
|
|
32
|
-
'libvips.lib'
|
|
33
|
-
'libglib-2.0.lib',
|
|
34
|
-
'libgobject-2.0.lib'
|
|
40
|
+
'libvips.lib'
|
|
35
41
|
],
|
|
36
42
|
},
|
|
37
43
|
'configurations': {
|
|
@@ -70,7 +76,7 @@
|
|
|
70
76
|
}, {
|
|
71
77
|
'target_name': 'sharp-<(platform_and_arch)',
|
|
72
78
|
'defines': [
|
|
73
|
-
'NAPI_VERSION=
|
|
79
|
+
'NAPI_VERSION=9',
|
|
74
80
|
'NODE_ADDON_API_DISABLE_DEPRECATED',
|
|
75
81
|
'NODE_API_SWALLOW_UNTHROWABLE_EXCEPTIONS'
|
|
76
82
|
],
|
|
@@ -79,11 +85,10 @@
|
|
|
79
85
|
'libvips-cpp'
|
|
80
86
|
],
|
|
81
87
|
'variables': {
|
|
82
|
-
'runtime_link%': 'shared',
|
|
83
88
|
'conditions': [
|
|
84
89
|
['OS != "win"', {
|
|
85
|
-
'pkg_config_path': '<!(node -p "require(\'
|
|
86
|
-
'use_global_libvips': '<!(node -p "Boolean(require(\'
|
|
90
|
+
'pkg_config_path': '<!(node -p "require(\'../lib/libvips\').pkgConfigPath()")',
|
|
91
|
+
'use_global_libvips': '<!(node -p "Boolean(require(\'../lib/libvips\').useGlobalLibvips()).toString()")'
|
|
87
92
|
}, {
|
|
88
93
|
'pkg_config_path': '',
|
|
89
94
|
'use_global_libvips': ''
|
|
@@ -91,13 +96,13 @@
|
|
|
91
96
|
]
|
|
92
97
|
},
|
|
93
98
|
'sources': [
|
|
94
|
-
'
|
|
95
|
-
'
|
|
96
|
-
'
|
|
97
|
-
'
|
|
98
|
-
'
|
|
99
|
-
'
|
|
100
|
-
'
|
|
99
|
+
'common.cc',
|
|
100
|
+
'metadata.cc',
|
|
101
|
+
'stats.cc',
|
|
102
|
+
'operations.cc',
|
|
103
|
+
'pipeline.cc',
|
|
104
|
+
'utilities.cc',
|
|
105
|
+
'sharp.cc'
|
|
101
106
|
],
|
|
102
107
|
'include_dirs': [
|
|
103
108
|
'<!(node -p "require(\'node-addon-api\').include_dir")',
|
|
@@ -106,12 +111,11 @@
|
|
|
106
111
|
['use_global_libvips == "true"', {
|
|
107
112
|
# Use pkg-config for include and lib
|
|
108
113
|
'include_dirs': ['<!@(PKG_CONFIG_PATH="<(pkg_config_path)" pkg-config --cflags-only-I vips-cpp vips glib-2.0 | sed s\/-I//g)'],
|
|
114
|
+
'libraries': ['<!@(PKG_CONFIG_PATH="<(pkg_config_path)" pkg-config --libs vips-cpp)'],
|
|
115
|
+
'defines': [
|
|
116
|
+
'SHARP_USE_GLOBAL_LIBVIPS'
|
|
117
|
+
],
|
|
109
118
|
'conditions': [
|
|
110
|
-
['runtime_link == "static"', {
|
|
111
|
-
'libraries': ['<!@(PKG_CONFIG_PATH="<(pkg_config_path)" pkg-config --libs --static vips-cpp)']
|
|
112
|
-
}, {
|
|
113
|
-
'libraries': ['<!@(PKG_CONFIG_PATH="<(pkg_config_path)" pkg-config --libs vips-cpp)']
|
|
114
|
-
}],
|
|
115
119
|
['OS == "linux"', {
|
|
116
120
|
'defines': [
|
|
117
121
|
# Inspect libvips-cpp.so to determine which C++11 ABI version was used and set _GLIBCXX_USE_CXX11_ABI accordingly. This is quite horrible.
|
|
@@ -122,9 +126,12 @@
|
|
|
122
126
|
}, {
|
|
123
127
|
# Use pre-built libvips stored locally within node_modules
|
|
124
128
|
'include_dirs': [
|
|
125
|
-
'<(
|
|
126
|
-
'<(
|
|
127
|
-
'<(
|
|
129
|
+
'<(sharp_libvips_include_dir)',
|
|
130
|
+
'<(sharp_libvips_include_dir)/glib-2.0',
|
|
131
|
+
'<(sharp_libvips_lib_dir)/glib-2.0/include'
|
|
132
|
+
],
|
|
133
|
+
'library_dirs': [
|
|
134
|
+
'<(sharp_libvips_lib_dir)'
|
|
128
135
|
],
|
|
129
136
|
'conditions': [
|
|
130
137
|
['OS == "win"', {
|
|
@@ -133,17 +140,13 @@
|
|
|
133
140
|
'_FILE_OFFSET_BITS=64'
|
|
134
141
|
],
|
|
135
142
|
'link_settings': {
|
|
136
|
-
'library_dirs': ['<(sharp_vendor_dir)/lib'],
|
|
137
143
|
'libraries': [
|
|
138
|
-
'libvips.lib'
|
|
139
|
-
'libglib-2.0.lib',
|
|
140
|
-
'libgobject-2.0.lib'
|
|
144
|
+
'libvips.lib'
|
|
141
145
|
]
|
|
142
146
|
}
|
|
143
147
|
}],
|
|
144
148
|
['OS == "mac"', {
|
|
145
149
|
'link_settings': {
|
|
146
|
-
'library_dirs': ['../<(sharp_vendor_dir)/lib'],
|
|
147
150
|
'libraries': [
|
|
148
151
|
'libvips-cpp.42.dylib'
|
|
149
152
|
]
|
|
@@ -151,7 +154,10 @@
|
|
|
151
154
|
'xcode_settings': {
|
|
152
155
|
'OTHER_LDFLAGS': [
|
|
153
156
|
# Ensure runtime linking is relative to sharp.node
|
|
154
|
-
'-Wl,-rpath,\'@loader_path
|
|
157
|
+
'-Wl,-rpath,\'@loader_path/../../sharp-libvips-<(platform_and_arch)/lib\'',
|
|
158
|
+
'-Wl,-rpath,\'@loader_path/../../../sharp-libvips-<(platform_and_arch)/<(sharp_libvips_version)/lib\'',
|
|
159
|
+
'-Wl,-rpath,\'@loader_path/../../node_modules/@img/sharp-libvips-<(platform_and_arch)/lib\'',
|
|
160
|
+
'-Wl,-rpath,\'@loader_path/../../../node_modules/@img/sharp-libvips-<(platform_and_arch)/lib\''
|
|
155
161
|
]
|
|
156
162
|
}
|
|
157
163
|
}],
|
|
@@ -160,15 +166,39 @@
|
|
|
160
166
|
'_GLIBCXX_USE_CXX11_ABI=1'
|
|
161
167
|
],
|
|
162
168
|
'link_settings': {
|
|
163
|
-
'library_dirs': ['../<(sharp_vendor_dir)/lib'],
|
|
164
169
|
'libraries': [
|
|
165
170
|
'-l:libvips-cpp.so.42'
|
|
166
171
|
],
|
|
167
172
|
'ldflags': [
|
|
168
|
-
|
|
169
|
-
'-Wl
|
|
173
|
+
'-Wl,-s',
|
|
174
|
+
'-Wl,--disable-new-dtags',
|
|
175
|
+
'-Wl,-z,nodelete',
|
|
176
|
+
'-Wl,-rpath=\'$$ORIGIN/../../sharp-libvips-<(platform_and_arch)/lib\'',
|
|
177
|
+
'-Wl,-rpath=\'$$ORIGIN/../../../sharp-libvips-<(platform_and_arch)/<(sharp_libvips_version)/lib\'',
|
|
178
|
+
'-Wl,-rpath=\'$$ORIGIN/../../node_modules/@img/sharp-libvips-<(platform_and_arch)/lib\'',
|
|
179
|
+
'-Wl,-rpath=\'$$ORIGIN/../../../node_modules/@img/sharp-libvips-<(platform_and_arch)/lib\''
|
|
170
180
|
]
|
|
171
181
|
}
|
|
182
|
+
}],
|
|
183
|
+
['OS == "emscripten"', {
|
|
184
|
+
'product_extension': 'node.js',
|
|
185
|
+
'link_settings': {
|
|
186
|
+
'ldflags': [
|
|
187
|
+
'-fexceptions',
|
|
188
|
+
'--pre-js=<!(node -p "require.resolve(\'./emscripten/pre.js\')")',
|
|
189
|
+
'-Oz',
|
|
190
|
+
'-sALLOW_MEMORY_GROWTH',
|
|
191
|
+
'-sENVIRONMENT=node',
|
|
192
|
+
'-sEXPORTED_FUNCTIONS=["_vips_shutdown", "_uv_library_shutdown"]',
|
|
193
|
+
'-sNODERAWFS',
|
|
194
|
+
'-sTEXTDECODER=0',
|
|
195
|
+
'-sWASM_ASYNC_COMPILATION=0',
|
|
196
|
+
'-sWASM_BIGINT'
|
|
197
|
+
],
|
|
198
|
+
'libraries': [
|
|
199
|
+
'<!@(PKG_CONFIG_PATH="<!(node -p "require(\'@img/sharp-libvips-dev-wasm32/lib\')")/pkgconfig" pkg-config --static --libs vips-cpp)'
|
|
200
|
+
],
|
|
201
|
+
}
|
|
172
202
|
}]
|
|
173
203
|
]
|
|
174
204
|
}]
|
|
@@ -232,5 +262,21 @@
|
|
|
232
262
|
]
|
|
233
263
|
}
|
|
234
264
|
},
|
|
265
|
+
}, {
|
|
266
|
+
'target_name': 'copy-dll',
|
|
267
|
+
'type': 'none',
|
|
268
|
+
'dependencies': [
|
|
269
|
+
'sharp-<(platform_and_arch)'
|
|
270
|
+
],
|
|
271
|
+
'conditions': [
|
|
272
|
+
['OS == "win"', {
|
|
273
|
+
'copies': [{
|
|
274
|
+
'destination': 'build/Release',
|
|
275
|
+
'files': [
|
|
276
|
+
'<(sharp_libvips_lib_dir)/libvips-42.dll'
|
|
277
|
+
]
|
|
278
|
+
}]
|
|
279
|
+
}]
|
|
280
|
+
]
|
|
235
281
|
}]
|
|
236
282
|
}
|
package/src/common.cc
CHANGED
|
@@ -166,10 +166,10 @@ namespace sharp {
|
|
|
166
166
|
}
|
|
167
167
|
|
|
168
168
|
// How many tasks are in the queue?
|
|
169
|
-
|
|
169
|
+
std::atomic<int> counterQueue{0};
|
|
170
170
|
|
|
171
171
|
// How many tasks are being processed?
|
|
172
|
-
|
|
172
|
+
std::atomic<int> counterProcess{0};
|
|
173
173
|
|
|
174
174
|
// Filename extension checkers
|
|
175
175
|
static bool EndsWith(std::string const &str, std::string const &end) {
|
|
@@ -363,12 +363,13 @@ namespace sharp {
|
|
|
363
363
|
if (descriptor->isBuffer) {
|
|
364
364
|
if (descriptor->rawChannels > 0) {
|
|
365
365
|
// Raw, uncompressed pixel data
|
|
366
|
+
bool const is8bit = vips_band_format_is8bit(descriptor->rawDepth);
|
|
366
367
|
image = VImage::new_from_memory(descriptor->buffer, descriptor->bufferLength,
|
|
367
368
|
descriptor->rawWidth, descriptor->rawHeight, descriptor->rawChannels, descriptor->rawDepth);
|
|
368
369
|
if (descriptor->rawChannels < 3) {
|
|
369
|
-
image.get_image()->Type = VIPS_INTERPRETATION_B_W;
|
|
370
|
+
image.get_image()->Type = is8bit ? VIPS_INTERPRETATION_B_W : VIPS_INTERPRETATION_GREY16;
|
|
370
371
|
} else {
|
|
371
|
-
image.get_image()->Type = VIPS_INTERPRETATION_sRGB;
|
|
372
|
+
image.get_image()->Type = is8bit ? VIPS_INTERPRETATION_sRGB : VIPS_INTERPRETATION_RGB16;
|
|
372
373
|
}
|
|
373
374
|
if (descriptor->rawPremultiplied) {
|
|
374
375
|
image = image.unpremultiply();
|
package/src/common.h
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
#include <string>
|
|
8
8
|
#include <tuple>
|
|
9
9
|
#include <vector>
|
|
10
|
+
#include <atomic>
|
|
10
11
|
|
|
11
12
|
#include <napi.h>
|
|
12
13
|
#include <vips/vips8>
|
|
@@ -14,9 +15,9 @@
|
|
|
14
15
|
// Verify platform and compiler compatibility
|
|
15
16
|
|
|
16
17
|
#if (VIPS_MAJOR_VERSION < 8) || \
|
|
17
|
-
(VIPS_MAJOR_VERSION == 8 && VIPS_MINOR_VERSION <
|
|
18
|
-
(VIPS_MAJOR_VERSION == 8 && VIPS_MINOR_VERSION ==
|
|
19
|
-
#error "libvips version 8.
|
|
18
|
+
(VIPS_MAJOR_VERSION == 8 && VIPS_MINOR_VERSION < 15) || \
|
|
19
|
+
(VIPS_MAJOR_VERSION == 8 && VIPS_MINOR_VERSION == 15 && VIPS_MICRO_VERSION < 0)
|
|
20
|
+
#error "libvips version 8.15.0+ is required - please see https://sharp.pixelplumbing.com/install"
|
|
20
21
|
#endif
|
|
21
22
|
|
|
22
23
|
#if ((!defined(__clang__)) && defined(__GNUC__) && (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 6)))
|
|
@@ -161,10 +162,10 @@ namespace sharp {
|
|
|
161
162
|
};
|
|
162
163
|
|
|
163
164
|
// How many tasks are in the queue?
|
|
164
|
-
extern
|
|
165
|
+
extern std::atomic<int> counterQueue;
|
|
165
166
|
|
|
166
167
|
// How many tasks are being processed?
|
|
167
|
-
extern
|
|
168
|
+
extern std::atomic<int> counterProcess;
|
|
168
169
|
|
|
169
170
|
// Filename extension checkers
|
|
170
171
|
bool IsJpeg(std::string const &str);
|
package/src/metadata.cc
CHANGED
|
@@ -18,7 +18,7 @@ class MetadataWorker : public Napi::AsyncWorker {
|
|
|
18
18
|
|
|
19
19
|
void Execute() {
|
|
20
20
|
// Decrement queued task counter
|
|
21
|
-
|
|
21
|
+
sharp::counterQueue--;
|
|
22
22
|
|
|
23
23
|
vips::VImage image;
|
|
24
24
|
sharp::ImageType imageType = sharp::ImageType::UNKNOWN;
|
|
@@ -145,7 +145,7 @@ class MetadataWorker : public Napi::AsyncWorker {
|
|
|
145
145
|
// Handle warnings
|
|
146
146
|
std::string warning = sharp::VipsWarningPop();
|
|
147
147
|
while (!warning.empty()) {
|
|
148
|
-
debuglog.
|
|
148
|
+
debuglog.Call(Receiver().Value(), { Napi::String::New(env, warning) });
|
|
149
149
|
warning = sharp::VipsWarningPop();
|
|
150
150
|
}
|
|
151
151
|
|
|
@@ -246,9 +246,9 @@ class MetadataWorker : public Napi::AsyncWorker {
|
|
|
246
246
|
Napi::Buffer<char>::NewOrCopy(env, baton->tifftagPhotoshop,
|
|
247
247
|
baton->tifftagPhotoshopLength, sharp::FreeCallback));
|
|
248
248
|
}
|
|
249
|
-
Callback().
|
|
249
|
+
Callback().Call(Receiver().Value(), { env.Null(), info });
|
|
250
250
|
} else {
|
|
251
|
-
Callback().
|
|
251
|
+
Callback().Call(Receiver().Value(), { Napi::Error::New(env, sharp::TrimEnd(baton->err)).Value() });
|
|
252
252
|
}
|
|
253
253
|
|
|
254
254
|
delete baton->input;
|
|
@@ -281,7 +281,7 @@ Napi::Value metadata(const Napi::CallbackInfo& info) {
|
|
|
281
281
|
worker->Queue();
|
|
282
282
|
|
|
283
283
|
// Increment queued task counter
|
|
284
|
-
|
|
284
|
+
sharp::counterQueue++;
|
|
285
285
|
|
|
286
286
|
return info.Env().Undefined();
|
|
287
287
|
}
|
package/src/operations.cc
CHANGED
|
@@ -141,7 +141,7 @@ namespace sharp {
|
|
|
141
141
|
return image.conv(blur);
|
|
142
142
|
} else {
|
|
143
143
|
// Slower, accurate Gaussian blur
|
|
144
|
-
return image.gaussblur(sigma);
|
|
144
|
+
return StaySequential(image, VIPS_ACCESS_SEQUENTIAL).gaussblur(sigma);
|
|
145
145
|
}
|
|
146
146
|
}
|
|
147
147
|
|
|
@@ -265,7 +265,7 @@ namespace sharp {
|
|
|
265
265
|
/*
|
|
266
266
|
Trim an image
|
|
267
267
|
*/
|
|
268
|
-
VImage Trim(VImage image, std::vector<double> background, double threshold) {
|
|
268
|
+
VImage Trim(VImage image, std::vector<double> background, double threshold, bool const lineArt) {
|
|
269
269
|
if (image.width() < 3 && image.height() < 3) {
|
|
270
270
|
throw VError("Image to trim must be at least 3x3 pixels");
|
|
271
271
|
}
|
|
@@ -287,6 +287,7 @@ namespace sharp {
|
|
|
287
287
|
int left, top, width, height;
|
|
288
288
|
left = image.find_trim(&top, &width, &height, VImage::option()
|
|
289
289
|
->set("background", background)
|
|
290
|
+
->set("line_art", lineArt)
|
|
290
291
|
->set("threshold", threshold));
|
|
291
292
|
if (HasAlpha(image)) {
|
|
292
293
|
// Search alpha channel (A)
|
|
@@ -294,6 +295,7 @@ namespace sharp {
|
|
|
294
295
|
VImage alpha = image[image.bands() - 1];
|
|
295
296
|
leftA = alpha.find_trim(&topA, &widthA, &heightA, VImage::option()
|
|
296
297
|
->set("background", backgroundAlpha)
|
|
298
|
+
->set("line_art", lineArt)
|
|
297
299
|
->set("threshold", threshold));
|
|
298
300
|
if (widthA > 0 && heightA > 0) {
|
|
299
301
|
if (width > 0 && height > 0) {
|
|
@@ -370,6 +372,7 @@ namespace sharp {
|
|
|
370
372
|
pages.reserve(nPages);
|
|
371
373
|
|
|
372
374
|
// Split the image into cropped frames
|
|
375
|
+
image = StaySequential(image, VIPS_ACCESS_SEQUENTIAL);
|
|
373
376
|
for (int i = 0; i < nPages; i++) {
|
|
374
377
|
pages.push_back(
|
|
375
378
|
image.extract_area(left, *pageHeight * i + top, width, height));
|
package/src/operations.h
CHANGED
|
@@ -79,7 +79,7 @@ namespace sharp {
|
|
|
79
79
|
/*
|
|
80
80
|
Trim an image
|
|
81
81
|
*/
|
|
82
|
-
VImage Trim(VImage image, std::vector<double> background, double const
|
|
82
|
+
VImage Trim(VImage image, std::vector<double> background, double threshold, bool const lineArt);
|
|
83
83
|
|
|
84
84
|
/*
|
|
85
85
|
* Linear adjustment (a * in + b)
|