mirror of
https://github.com/lovell/sharp.git
synced 2026-02-05 22:26:20 +01:00
Compare commits
12 Commits
v0.33.0-al
...
v0.33.0-al
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
68ac12292c | ||
|
|
a9aa7339ce | ||
|
|
08108f5fad | ||
|
|
58e3c4c70e | ||
|
|
f8cf25ca56 | ||
|
|
ca95979ecc | ||
|
|
392f6afb5e | ||
|
|
7c97aabaf8 | ||
|
|
fcc7e84bee | ||
|
|
226a9a13ef | ||
|
|
4d3c9ae3d1 | ||
|
|
f31011d759 |
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@@ -141,7 +141,7 @@ jobs:
|
|||||||
npm pkg set "optionalDependencies.@sharpen/sharp-linux-arm=file:./npm/linux-arm"
|
npm pkg set "optionalDependencies.@sharpen/sharp-linux-arm=file:./npm/linux-arm"
|
||||||
npm run clean
|
npm run clean
|
||||||
npm install --ignore-scripts
|
npm install --ignore-scripts
|
||||||
npx mocha --no-config --spec=test/unit/io.js
|
npx mocha --no-config --spec=test/unit/io.js --timeout=30000
|
||||||
[[ -n $prebuild_upload ]] && npx prebuild || true
|
[[ -n $prebuild_upload ]] && npx prebuild || true
|
||||||
macstadium-runner:
|
macstadium-runner:
|
||||||
permissions:
|
permissions:
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
'sharp_libvips_lib_dir': '<!(node -p "require(\'./lib/libvips\').buildSharpLibvipsLibDir()")'
|
'sharp_libvips_lib_dir': '<!(node -p "require(\'./lib/libvips\').buildSharpLibvipsLibDir()")'
|
||||||
},
|
},
|
||||||
'targets': [{
|
'targets': [{
|
||||||
'target_name': 'win-libvips-cpp',
|
'target_name': 'libvips-cpp',
|
||||||
'conditions': [
|
'conditions': [
|
||||||
['OS == "win"', {
|
['OS == "win"', {
|
||||||
# Build libvips C++ binding for Windows due to MSVC std library ABI changes
|
# Build libvips C++ binding for Windows due to MSVC std library ABI changes
|
||||||
@@ -81,7 +81,7 @@
|
|||||||
],
|
],
|
||||||
'dependencies': [
|
'dependencies': [
|
||||||
'<!(node -p "require(\'node-addon-api\').gyp")',
|
'<!(node -p "require(\'node-addon-api\').gyp")',
|
||||||
'win-libvips-cpp'
|
'libvips-cpp'
|
||||||
],
|
],
|
||||||
'variables': {
|
'variables': {
|
||||||
'conditions': [
|
'conditions': [
|
||||||
@@ -243,7 +243,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
}, {
|
}, {
|
||||||
'target_name': 'win-copy-dlls',
|
'target_name': 'copy-dll',
|
||||||
'type': 'none',
|
'type': 'none',
|
||||||
'dependencies': [
|
'dependencies': [
|
||||||
'sharp-<(platform_and_arch)'
|
'sharp-<(platform_and_arch)'
|
||||||
|
|||||||
@@ -13,6 +13,9 @@ Requires libvips v8.14.5
|
|||||||
* Make `compression` option of `heif` mandatory to help reduce HEIF vs HEIC confusion.
|
* Make `compression` option of `heif` mandatory to help reduce HEIF vs HEIC confusion.
|
||||||
[#3740](https://github.com/lovell/sharp/issues/3740)
|
[#3740](https://github.com/lovell/sharp/issues/3740)
|
||||||
|
|
||||||
|
* Ensure correct interpretation of 16-bit raw input.
|
||||||
|
[#3808](https://github.com/lovell/sharp/issues/3808)
|
||||||
|
|
||||||
## v0.32 - *flow*
|
## v0.32 - *flow*
|
||||||
|
|
||||||
Requires libvips v8.14.5
|
Requires libvips v8.14.5
|
||||||
|
|||||||
@@ -3,8 +3,8 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const util = require('util');
|
const util = require('node:util');
|
||||||
const stream = require('stream');
|
const stream = require('node:stream');
|
||||||
const is = require('./is');
|
const is = require('./is');
|
||||||
|
|
||||||
require('./sharp');
|
require('./sharp');
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const spawnSync = require('child_process').spawnSync;
|
const { spawnSync } = require('node:child_process');
|
||||||
const semverCoerce = require('semver/functions/coerce');
|
const semverCoerce = require('semver/functions/coerce');
|
||||||
const semverGreaterThanOrEqualTo = require('semver/functions/gte');
|
const semverGreaterThanOrEqualTo = require('semver/functions/gte');
|
||||||
const detectLibc = require('detect-libc');
|
const detectLibc = require('detect-libc');
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const path = require('path');
|
const path = require('node:path');
|
||||||
const is = require('./is');
|
const is = require('./is');
|
||||||
const sharp = require('./sharp');
|
const sharp = require('./sharp');
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const events = require('events');
|
const events = require('node:events');
|
||||||
const detectLibc = require('detect-libc');
|
const detectLibc = require('detect-libc');
|
||||||
|
|
||||||
const is = require('./is');
|
const is = require('./is');
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@sharpen/sharp-darwin-arm64",
|
"name": "@sharpen/sharp-darwin-arm64",
|
||||||
"version": "0.0.1-alpha.1",
|
"version": "0.0.1-alpha.4",
|
||||||
"description": "Prebuilt sharp for use with macOS ARM64",
|
"description": "Prebuilt sharp for use with macOS ARM64",
|
||||||
"homepage": "https://sharp.pixelplumbing.com",
|
"homepage": "https://sharp.pixelplumbing.com",
|
||||||
"repository": {
|
"repository": {
|
||||||
@@ -22,6 +22,7 @@
|
|||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"access": "public"
|
"access": "public"
|
||||||
},
|
},
|
||||||
|
"type": "commonjs",
|
||||||
"exports": {
|
"exports": {
|
||||||
"./sharp.node": "./lib/sharp-darwin-arm64.node",
|
"./sharp.node": "./lib/sharp-darwin-arm64.node",
|
||||||
"./package": "./package.json"
|
"./package": "./package.json"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@sharpen/sharp-darwin-x64",
|
"name": "@sharpen/sharp-darwin-x64",
|
||||||
"version": "0.0.1-alpha.1",
|
"version": "0.0.1-alpha.4",
|
||||||
"description": "Prebuilt sharp for use with macOS x64",
|
"description": "Prebuilt sharp for use with macOS x64",
|
||||||
"homepage": "https://sharp.pixelplumbing.com",
|
"homepage": "https://sharp.pixelplumbing.com",
|
||||||
"repository": {
|
"repository": {
|
||||||
@@ -22,6 +22,7 @@
|
|||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"access": "public"
|
"access": "public"
|
||||||
},
|
},
|
||||||
|
"type": "commonjs",
|
||||||
"exports": {
|
"exports": {
|
||||||
"./sharp.node": "./lib/sharp-darwin-x64.node",
|
"./sharp.node": "./lib/sharp-darwin-x64.node",
|
||||||
"./package": "./package.json"
|
"./package": "./package.json"
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
// Populate contents of all packages with the current GitHub release
|
// Populate contents of all packages with the current GitHub release
|
||||||
|
|
||||||
const { writeFile, copyFile } = require('node:fs/promises');
|
const { writeFile, copyFile, rm } = require('node:fs/promises');
|
||||||
const path = require('node:path');
|
const path = require('node:path');
|
||||||
const { Readable } = require('node:stream');
|
const { Readable } = require('node:stream');
|
||||||
const { pipeline } = require('node:stream/promises');
|
const { pipeline } = require('node:stream/promises');
|
||||||
@@ -46,10 +46,12 @@ workspaces.map(async platform => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Extract prebuild tarball
|
// Extract prebuild tarball
|
||||||
|
const lib = path.join(dir, 'lib');
|
||||||
|
await rm(lib, { recursive: true });
|
||||||
await pipeline(
|
await pipeline(
|
||||||
Readable.fromWeb(response.body),
|
Readable.fromWeb(response.body),
|
||||||
createGunzip(),
|
createGunzip(),
|
||||||
extract(path.join(dir, 'lib'), { map: mapTarballEntry })
|
extract(lib, { map: mapTarballEntry })
|
||||||
);
|
);
|
||||||
// Generate README
|
// Generate README
|
||||||
const { name, description } = require(`./${platform}/package.json`);
|
const { name, description } = require(`./${platform}/package.json`);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@sharpen/sharp-linux-arm",
|
"name": "@sharpen/sharp-linux-arm",
|
||||||
"version": "0.0.1-alpha.1",
|
"version": "0.0.1-alpha.4",
|
||||||
"description": "Prebuilt sharp for use with Linux (glibc) ARM (32-bit)",
|
"description": "Prebuilt sharp for use with Linux (glibc) ARM (32-bit)",
|
||||||
"homepage": "https://sharp.pixelplumbing.com",
|
"homepage": "https://sharp.pixelplumbing.com",
|
||||||
"repository": {
|
"repository": {
|
||||||
@@ -22,6 +22,7 @@
|
|||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"access": "public"
|
"access": "public"
|
||||||
},
|
},
|
||||||
|
"type": "commonjs",
|
||||||
"exports": {
|
"exports": {
|
||||||
"./sharp.node": "./lib/sharp-linux-arm.node",
|
"./sharp.node": "./lib/sharp-linux-arm.node",
|
||||||
"./package": "./package.json"
|
"./package": "./package.json"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@sharpen/sharp-linux-arm64",
|
"name": "@sharpen/sharp-linux-arm64",
|
||||||
"version": "0.0.1-alpha.1",
|
"version": "0.0.1-alpha.4",
|
||||||
"description": "Prebuilt sharp for use with Linux (glibc) ARM64",
|
"description": "Prebuilt sharp for use with Linux (glibc) ARM64",
|
||||||
"homepage": "https://sharp.pixelplumbing.com",
|
"homepage": "https://sharp.pixelplumbing.com",
|
||||||
"repository": {
|
"repository": {
|
||||||
@@ -22,6 +22,7 @@
|
|||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"access": "public"
|
"access": "public"
|
||||||
},
|
},
|
||||||
|
"type": "commonjs",
|
||||||
"exports": {
|
"exports": {
|
||||||
"./sharp.node": "./lib/sharp-linux-arm64.node",
|
"./sharp.node": "./lib/sharp-linux-arm64.node",
|
||||||
"./package": "./package.json"
|
"./package": "./package.json"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@sharpen/sharp-linux-x64",
|
"name": "@sharpen/sharp-linux-x64",
|
||||||
"version": "0.0.1-alpha.1",
|
"version": "0.0.1-alpha.4",
|
||||||
"description": "Prebuilt sharp for use with Linux (glibc) x64",
|
"description": "Prebuilt sharp for use with Linux (glibc) x64",
|
||||||
"homepage": "https://sharp.pixelplumbing.com",
|
"homepage": "https://sharp.pixelplumbing.com",
|
||||||
"repository": {
|
"repository": {
|
||||||
@@ -22,6 +22,7 @@
|
|||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"access": "public"
|
"access": "public"
|
||||||
},
|
},
|
||||||
|
"type": "commonjs",
|
||||||
"exports": {
|
"exports": {
|
||||||
"./sharp.node": "./lib/sharp-linux-x64.node",
|
"./sharp.node": "./lib/sharp-linux-x64.node",
|
||||||
"./package": "./package.json"
|
"./package": "./package.json"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@sharpen/sharp-linuxmusl-arm64",
|
"name": "@sharpen/sharp-linuxmusl-arm64",
|
||||||
"version": "0.0.1-alpha.1",
|
"version": "0.0.1-alpha.4",
|
||||||
"description": "Prebuilt sharp for use with Linux (musl) ARM64",
|
"description": "Prebuilt sharp for use with Linux (musl) ARM64",
|
||||||
"homepage": "https://sharp.pixelplumbing.com",
|
"homepage": "https://sharp.pixelplumbing.com",
|
||||||
"repository": {
|
"repository": {
|
||||||
@@ -22,6 +22,7 @@
|
|||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"access": "public"
|
"access": "public"
|
||||||
},
|
},
|
||||||
|
"type": "commonjs",
|
||||||
"exports": {
|
"exports": {
|
||||||
"./sharp.node": "./lib/sharp-linuxmusl-arm64.node",
|
"./sharp.node": "./lib/sharp-linuxmusl-arm64.node",
|
||||||
"./package": "./package.json"
|
"./package": "./package.json"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@sharpen/sharp-linuxmusl-x64",
|
"name": "@sharpen/sharp-linuxmusl-x64",
|
||||||
"version": "0.0.1-alpha.1",
|
"version": "0.0.1-alpha.4",
|
||||||
"description": "Prebuilt sharp for use with Linux (musl) x64",
|
"description": "Prebuilt sharp for use with Linux (musl) x64",
|
||||||
"homepage": "https://sharp.pixelplumbing.com",
|
"homepage": "https://sharp.pixelplumbing.com",
|
||||||
"repository": {
|
"repository": {
|
||||||
@@ -22,6 +22,7 @@
|
|||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"access": "public"
|
"access": "public"
|
||||||
},
|
},
|
||||||
|
"type": "commonjs",
|
||||||
"exports": {
|
"exports": {
|
||||||
"./sharp.node": "./lib/sharp-linuxmusl-x64.node",
|
"./sharp.node": "./lib/sharp-linuxmusl-x64.node",
|
||||||
"./package": "./package.json"
|
"./package": "./package.json"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@sharpen/sharp-win32-ia32",
|
"name": "@sharpen/sharp-win32-ia32",
|
||||||
"version": "0.0.1-alpha.1",
|
"version": "0.0.1-alpha.4",
|
||||||
"description": "Prebuilt sharp for use with Windows x86 (32-bit)",
|
"description": "Prebuilt sharp for use with Windows x86 (32-bit)",
|
||||||
"homepage": "https://sharp.pixelplumbing.com",
|
"homepage": "https://sharp.pixelplumbing.com",
|
||||||
"repository": {
|
"repository": {
|
||||||
@@ -13,18 +13,19 @@
|
|||||||
"url": "https://opencollective.com/libvips"
|
"url": "https://opencollective.com/libvips"
|
||||||
},
|
},
|
||||||
"preferUnplugged": true,
|
"preferUnplugged": true,
|
||||||
"optionalDependencies": {
|
|
||||||
"@sharpen/sharp-libvips-win32-ia32": "0.0.1-alpha.1"
|
|
||||||
},
|
|
||||||
"files": [
|
"files": [
|
||||||
"lib"
|
"lib",
|
||||||
|
"versions.json",
|
||||||
|
"THIRD-PARTY-NOTICES.md"
|
||||||
],
|
],
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"access": "public"
|
"access": "public"
|
||||||
},
|
},
|
||||||
|
"type": "commonjs",
|
||||||
"exports": {
|
"exports": {
|
||||||
"./sharp.node": "./lib/sharp-win32-ia32.node",
|
"./sharp.node": "./lib/sharp-win32-ia32.node",
|
||||||
"./package": "./package.json"
|
"./package": "./package.json",
|
||||||
|
"./versions": "./versions.json"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "^18.17.0 || ^20.3.0 || >=21.0.0",
|
"node": "^18.17.0 || ^20.3.0 || >=21.0.0",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@sharpen/sharp-win32-x64",
|
"name": "@sharpen/sharp-win32-x64",
|
||||||
"version": "0.0.1-alpha.1",
|
"version": "0.0.1-alpha.4",
|
||||||
"description": "Prebuilt sharp for use with Windows x64",
|
"description": "Prebuilt sharp for use with Windows x64",
|
||||||
"homepage": "https://sharp.pixelplumbing.com",
|
"homepage": "https://sharp.pixelplumbing.com",
|
||||||
"repository": {
|
"repository": {
|
||||||
@@ -13,15 +13,15 @@
|
|||||||
"url": "https://opencollective.com/libvips"
|
"url": "https://opencollective.com/libvips"
|
||||||
},
|
},
|
||||||
"preferUnplugged": true,
|
"preferUnplugged": true,
|
||||||
"optionalDependencies": {
|
|
||||||
"@sharpen/sharp-libvips-win32-x64": "0.0.1-alpha.1"
|
|
||||||
},
|
|
||||||
"files": [
|
"files": [
|
||||||
"lib"
|
"lib",
|
||||||
|
"versions.json",
|
||||||
|
"THIRD-PARTY-NOTICES.md"
|
||||||
],
|
],
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"access": "public"
|
"access": "public"
|
||||||
},
|
},
|
||||||
|
"type": "commonjs",
|
||||||
"exports": {
|
"exports": {
|
||||||
"./sharp.node": "./lib/sharp-win32-x64.node",
|
"./sharp.node": "./lib/sharp-win32-x64.node",
|
||||||
"./package": "./package.json"
|
"./package": "./package.json"
|
||||||
|
|||||||
47
package.json
47
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.33.0-alpha.2",
|
"version": "0.33.0-alpha.4",
|
||||||
"author": "Lovell Fuller <npm@lovell.info>",
|
"author": "Lovell Fuller <npm@lovell.info>",
|
||||||
"homepage": "https://github.com/lovell/sharp",
|
"homepage": "https://github.com/lovell/sharp",
|
||||||
"contributors": [
|
"contributors": [
|
||||||
@@ -103,13 +103,14 @@
|
|||||||
"docs-serve": "cd docs && npx serve",
|
"docs-serve": "cd docs && npx serve",
|
||||||
"docs-publish": "cd docs && npx firebase-tools deploy --project pixelplumbing --only hosting:pixelplumbing-sharp"
|
"docs-publish": "cd docs && npx firebase-tools deploy --project pixelplumbing --only hosting:pixelplumbing-sharp"
|
||||||
},
|
},
|
||||||
|
"type": "commonjs",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"types": "lib/index.d.ts",
|
"types": "lib/index.d.ts",
|
||||||
"files": [
|
"files": [
|
||||||
"binding.gyp",
|
"binding.gyp",
|
||||||
"install/**",
|
"install",
|
||||||
"lib/**",
|
"lib",
|
||||||
"src/**"
|
"src"
|
||||||
],
|
],
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@@ -140,27 +141,27 @@
|
|||||||
"semver": "^7.5.4"
|
"semver": "^7.5.4"
|
||||||
},
|
},
|
||||||
"optionalDependencies": {
|
"optionalDependencies": {
|
||||||
"@sharpen/sharp-darwin-arm64": "0.0.1-alpha.2",
|
"@sharpen/sharp-darwin-arm64": "0.0.1-alpha.4",
|
||||||
"@sharpen/sharp-darwin-x64": "0.0.1-alpha.2",
|
"@sharpen/sharp-darwin-x64": "0.0.1-alpha.4",
|
||||||
"@sharpen/sharp-linux-arm": "0.0.1-alpha.2",
|
"@sharpen/sharp-libvips-darwin-arm64": "0.0.1-alpha.2",
|
||||||
"@sharpen/sharp-linux-arm64": "0.0.1-alpha.2",
|
"@sharpen/sharp-libvips-darwin-x64": "0.0.1-alpha.2",
|
||||||
"@sharpen/sharp-linux-x64": "0.0.1-alpha.2",
|
"@sharpen/sharp-libvips-linux-arm": "0.0.1-alpha.2",
|
||||||
"@sharpen/sharp-linuxmusl-arm64": "0.0.1-alpha.2",
|
"@sharpen/sharp-libvips-linux-arm64": "0.0.1-alpha.2",
|
||||||
"@sharpen/sharp-linuxmusl-x64": "0.0.1-alpha.2",
|
"@sharpen/sharp-libvips-linux-x64": "0.0.1-alpha.2",
|
||||||
"@sharpen/sharp-win32-ia32": "0.0.1-alpha.2",
|
"@sharpen/sharp-libvips-linuxmusl-arm64": "0.0.1-alpha.2",
|
||||||
"@sharpen/sharp-win32-x64": "0.0.1-alpha.2"
|
"@sharpen/sharp-libvips-linuxmusl-x64": "0.0.1-alpha.2",
|
||||||
|
"@sharpen/sharp-linux-arm": "0.0.1-alpha.4",
|
||||||
|
"@sharpen/sharp-linux-arm64": "0.0.1-alpha.4",
|
||||||
|
"@sharpen/sharp-linux-x64": "0.0.1-alpha.4",
|
||||||
|
"@sharpen/sharp-linuxmusl-arm64": "0.0.1-alpha.4",
|
||||||
|
"@sharpen/sharp-linuxmusl-x64": "0.0.1-alpha.4",
|
||||||
|
"@sharpen/sharp-win32-ia32": "0.0.1-alpha.4",
|
||||||
|
"@sharpen/sharp-win32-x64": "0.0.1-alpha.4"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@sharpen/sharp-libvips-darwin-arm64": "0.0.1-alpha.1",
|
"@sharpen/sharp-libvips-dev": "0.0.1-alpha.2",
|
||||||
"@sharpen/sharp-libvips-darwin-x64": "0.0.1-alpha.1",
|
"@sharpen/sharp-libvips-win32-ia32": "0.0.1-alpha.2",
|
||||||
"@sharpen/sharp-libvips-dev": "0.0.1-alpha.1",
|
"@sharpen/sharp-libvips-win32-x64": "0.0.1-alpha.2",
|
||||||
"@sharpen/sharp-libvips-linux-arm": "0.0.1-alpha.1",
|
|
||||||
"@sharpen/sharp-libvips-linux-arm64": "0.0.1-alpha.1",
|
|
||||||
"@sharpen/sharp-libvips-linux-x64": "0.0.1-alpha.1",
|
|
||||||
"@sharpen/sharp-libvips-linuxmusl-arm64": "0.0.1-alpha.1",
|
|
||||||
"@sharpen/sharp-libvips-linuxmusl-x64": "0.0.1-alpha.1",
|
|
||||||
"@sharpen/sharp-libvips-win32-ia32": "0.0.1-alpha.1",
|
|
||||||
"@sharpen/sharp-libvips-win32-x64": "0.0.1-alpha.1",
|
|
||||||
"@types/node": "*",
|
"@types/node": "*",
|
||||||
"async": "^3.2.4",
|
"async": "^3.2.4",
|
||||||
"cc": "^3.0.1",
|
"cc": "^3.0.1",
|
||||||
|
|||||||
@@ -363,12 +363,13 @@ namespace sharp {
|
|||||||
if (descriptor->isBuffer) {
|
if (descriptor->isBuffer) {
|
||||||
if (descriptor->rawChannels > 0) {
|
if (descriptor->rawChannels > 0) {
|
||||||
// Raw, uncompressed pixel data
|
// Raw, uncompressed pixel data
|
||||||
|
bool const is8bit = vips_band_format_is8bit(descriptor->rawDepth);
|
||||||
image = VImage::new_from_memory(descriptor->buffer, descriptor->bufferLength,
|
image = VImage::new_from_memory(descriptor->buffer, descriptor->bufferLength,
|
||||||
descriptor->rawWidth, descriptor->rawHeight, descriptor->rawChannels, descriptor->rawDepth);
|
descriptor->rawWidth, descriptor->rawHeight, descriptor->rawChannels, descriptor->rawDepth);
|
||||||
if (descriptor->rawChannels < 3) {
|
if (descriptor->rawChannels < 3) {
|
||||||
image.get_image()->Type = VIPS_INTERPRETATION_B_W;
|
image.get_image()->Type = is8bit ? VIPS_INTERPRETATION_B_W : VIPS_INTERPRETATION_GREY16;
|
||||||
} else {
|
} else {
|
||||||
image.get_image()->Type = VIPS_INTERPRETATION_sRGB;
|
image.get_image()->Type = is8bit ? VIPS_INTERPRETATION_sRGB : VIPS_INTERPRETATION_RGB16;
|
||||||
}
|
}
|
||||||
if (descriptor->rawPremultiplied) {
|
if (descriptor->rawPremultiplied) {
|
||||||
image = image.unpremultiply();
|
image = image.unpremultiply();
|
||||||
|
|||||||
13
src/sharp.cc
13
src/sharp.cc
@@ -1,6 +1,8 @@
|
|||||||
// Copyright 2013 Lovell Fuller and others.
|
// Copyright 2013 Lovell Fuller and others.
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
#include <mutex> // NOLINT(build/c++11)
|
||||||
|
|
||||||
#include <napi.h>
|
#include <napi.h>
|
||||||
#include <vips/vips8>
|
#include <vips/vips8>
|
||||||
|
|
||||||
@@ -10,14 +12,11 @@
|
|||||||
#include "utilities.h"
|
#include "utilities.h"
|
||||||
#include "stats.h"
|
#include "stats.h"
|
||||||
|
|
||||||
static void* sharp_vips_init(void*) {
|
|
||||||
vips_init("sharp");
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
Napi::Object init(Napi::Env env, Napi::Object exports) {
|
Napi::Object init(Napi::Env env, Napi::Object exports) {
|
||||||
static GOnce sharp_vips_init_once = G_ONCE_INIT;
|
static std::once_flag sharp_vips_init_once;
|
||||||
g_once(&sharp_vips_init_once, static_cast<GThreadFunc>(sharp_vips_init), nullptr);
|
std::call_once(sharp_vips_init_once, []() {
|
||||||
|
vips_init("sharp");
|
||||||
|
});
|
||||||
|
|
||||||
g_log_set_handler("VIPS", static_cast<GLogLevelFlags>(G_LOG_LEVEL_WARNING),
|
g_log_set_handler("VIPS", static_cast<GLogLevelFlags>(G_LOG_LEVEL_WARNING),
|
||||||
static_cast<GLogFunc>(sharp::VipsWarningCallback), nullptr);
|
static_cast<GLogFunc>(sharp::VipsWarningCallback), nullptr);
|
||||||
|
|||||||
@@ -284,4 +284,42 @@ describe('Raw pixel data', function () {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('16-bit roundtrip', () => {
|
||||||
|
it('grey', async () => {
|
||||||
|
const grey = 42000;
|
||||||
|
const png = await sharp(
|
||||||
|
Uint16Array.from([grey]),
|
||||||
|
{ raw: { width: 1, height: 1, channels: 1 } }
|
||||||
|
)
|
||||||
|
.toColourspace('grey16')
|
||||||
|
.png({ compressionLevel: 0 })
|
||||||
|
.toBuffer();
|
||||||
|
const raw = await sharp(png)
|
||||||
|
.toColourspace('grey16')
|
||||||
|
.raw({ depth: 'ushort' })
|
||||||
|
.toBuffer();
|
||||||
|
|
||||||
|
assert.strictEqual(raw.readUint16LE(0), grey);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('RGB', async () => {
|
||||||
|
const rgb = [10946, 28657, 46368];
|
||||||
|
const png = await sharp(
|
||||||
|
Uint16Array.from(rgb),
|
||||||
|
{ raw: { width: 1, height: 1, channels: 3 } }
|
||||||
|
)
|
||||||
|
.toColourspace('rgb16')
|
||||||
|
.png({ compressionLevel: 0 })
|
||||||
|
.toBuffer();
|
||||||
|
const raw = await sharp(png)
|
||||||
|
.toColourspace('rgb16')
|
||||||
|
.raw({ depth: 'ushort' })
|
||||||
|
.toBuffer();
|
||||||
|
|
||||||
|
assert.strictEqual(raw.readUint16LE(0), rgb[0]);
|
||||||
|
assert.strictEqual(raw.readUint16LE(2), rgb[1]);
|
||||||
|
assert.strictEqual(raw.readUint16LE(4), rgb[2]);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user