Upgrade to libvips v8.7.0

Drop Node 4 support
Add experimental musl prebuild for Node 8 and 10
This commit is contained in:
Lovell Fuller 2018-09-19 21:38:09 +01:00
parent 4cff62258c
commit c8ff7e11a9
25 changed files with 500 additions and 411 deletions

View File

@ -1,34 +1,59 @@
language: node_js
matrix: matrix:
include: include:
- os: linux - name: "Linux (glibc) - Node 6"
dist: trusty os: linux
sudo: false
node_js: "4"
- os: linux
dist: trusty dist: trusty
sudo: false sudo: false
language: node_js
node_js: "6" node_js: "6"
- os: linux - name: "Linux (glibc) - Node 8"
os: linux
dist: trusty dist: trusty
sudo: false sudo: false
language: node_js
node_js: "8" node_js: "8"
- os: linux - name: "Linux (glibc) - Node 10"
os: linux
dist: trusty dist: trusty
sudo: false sudo: false
language: node_js
node_js: "10" node_js: "10"
- os: osx after_success:
osx_image: xcode8.3 - npm install coveralls
node_js: "4" - cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js
- os: osx - name: "Linux (musl) - Node 8"
osx_image: xcode8.3 os: linux
dist: trusty
sudo: true
language: minimal
before_install:
- sudo docker run -dit --name sharp --env CI --env PREBUILD_TOKEN --volume "${PWD}:/mnt/sharp" --workdir /mnt/sharp node:8-alpine
- sudo docker exec sharp apk add build-base git python2 --update-cache
install: sudo docker exec sharp sh -c "npm install --unsafe-perm"
script: sudo docker exec sharp sh -c "npm test"
- name: "Linux (musl) - Node 10"
os: linux
dist: trusty
sudo: true
language: minimal
before_install:
- sudo docker run -dit --name sharp --env CI --env PREBUILD_TOKEN --volume "${PWD}:/mnt/sharp" --workdir /mnt/sharp node:10-alpine
- sudo docker exec sharp apk add build-base git python2 --update-cache
install: sudo docker exec sharp sh -c "npm install --unsafe-perm"
script: sudo docker exec sharp sh -c "npm test"
allow_failures:
- name: "OS X - Node 6"
os: osx
osx_image: xcode9.2
language: node_js
node_js: "6" node_js: "6"
- os: osx - name: "OS X - Node 8"
osx_image: xcode8.3 os: osx
osx_image: xcode9.2
language: node_js
node_js: "8" node_js: "8"
- os: osx - name: "OS X - Node 10"
osx_image: xcode8.3 os: osx
osx_image: xcode9.2
language: node_js
node_js: "10" node_js: "10"
after_success:
- npm install coveralls
- cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js

View File

@ -21,8 +21,8 @@ Lanczos resampling ensures quality is not sacrificed for speed.
As well as image resizing, operations such as As well as image resizing, operations such as
rotation, extraction, compositing and gamma correction are available. rotation, extraction, compositing and gamma correction are available.
Most modern 64-bit OS X, Windows and Linux (glibc) systems running Most modern 64-bit OS X, Windows and Linux systems running
Node versions 4, 6, 8 and 10 Node versions 6, 8 and 10
do not require any additional install or runtime dependencies. do not require any additional install or runtime dependencies.
## Examples ## Examples

View File

@ -4,7 +4,6 @@ build: off
platform: x64 platform: x64
environment: environment:
matrix: matrix:
- nodejs_version: "4"
- nodejs_version: "6" - nodejs_version: "6"
- nodejs_version: "8" - nodejs_version: "8"
- nodejs_version: "10" - nodejs_version: "10"

View File

@ -128,9 +128,11 @@
'../vendor/lib/libcairo.so', '../vendor/lib/libcairo.so',
'../vendor/lib/libcroco-0.6.so', '../vendor/lib/libcroco-0.6.so',
'../vendor/lib/libexif.so', '../vendor/lib/libexif.so',
'../vendor/lib/libexpat.so',
'../vendor/lib/libffi.so', '../vendor/lib/libffi.so',
'../vendor/lib/libfontconfig.so', '../vendor/lib/libfontconfig.so',
'../vendor/lib/libfreetype.so', '../vendor/lib/libfreetype.so',
'../vendor/lib/libfribidi.so',
'../vendor/lib/libgdk_pixbuf-2.0.so', '../vendor/lib/libgdk_pixbuf-2.0.so',
'../vendor/lib/libgif.so', '../vendor/lib/libgif.so',
'../vendor/lib/libgio-2.0.so', '../vendor/lib/libgio-2.0.so',
@ -138,6 +140,7 @@
'../vendor/lib/libgsf-1.so', '../vendor/lib/libgsf-1.so',
'../vendor/lib/libgthread-2.0.so', '../vendor/lib/libgthread-2.0.so',
'../vendor/lib/libharfbuzz.so', '../vendor/lib/libharfbuzz.so',
'../vendor/lib/libharfbuzz-subset.so.0',
'../vendor/lib/libjpeg.so', '../vendor/lib/libjpeg.so',
'../vendor/lib/liblcms2.so', '../vendor/lib/liblcms2.so',
'../vendor/lib/liborc-0.4.so', '../vendor/lib/liborc-0.4.so',
@ -149,6 +152,8 @@
'../vendor/lib/librsvg-2.so', '../vendor/lib/librsvg-2.so',
'../vendor/lib/libtiff.so', '../vendor/lib/libtiff.so',
'../vendor/lib/libwebp.so', '../vendor/lib/libwebp.so',
'../vendor/lib/libwebpdemux.so',
'../vendor/lib/libwebpmux.so',
'../vendor/lib/libxml2.so', '../vendor/lib/libxml2.so',
'../vendor/lib/libz.so', '../vendor/lib/libz.so',
# Ensure runtime linking is relative to sharp.node # Ensure runtime linking is relative to sharp.node

View File

@ -1,5 +1,17 @@
# Changelog # Changelog
### v0.21 - "*teeth*"
Requires libvips v8.7.0.
#### v0.21.0 - TBD
* Drop Node 4 support.
[#1212](https://github.com/lovell/sharp/issues/1212)
* Add experimental prebuilt binaries for musl-based Linux.
[#1379](https://github.com/lovell/sharp/issues/1379)
### v0.20 - "*prebuild*" ### v0.20 - "*prebuild*"
Requires libvips v8.6.1. Requires libvips v8.6.1.

View File

@ -13,8 +13,8 @@ Lanczos resampling ensures quality is not sacrificed for speed.
As well as image resizing, operations such as As well as image resizing, operations such as
rotation, extraction, compositing and gamma correction are available. rotation, extraction, compositing and gamma correction are available.
Most 64-bit OS X, Windows and Linux (glibc) systems running Most modern 64-bit OS X, Windows and Linux systems running
Node versions 4, 6, 8 and 10 Node versions 6, 8 and 10
do not require any additional install or runtime dependencies. do not require any additional install or runtime dependencies.
[![Test Coverage](https://coveralls.io/repos/lovell/sharp/badge.png?branch=master)](https://coveralls.io/r/lovell/sharp?branch=master) [![Test Coverage](https://coveralls.io/repos/lovell/sharp/badge.png?branch=master)](https://coveralls.io/r/lovell/sharp?branch=master)

View File

@ -15,7 +15,7 @@ yarn add sharp
### Building from source ### Building from source
Pre-compiled binaries for sharp are provided for use with Pre-compiled binaries for sharp are provided for use with
Node versions 4, 6, 8 and 10 on Node versions 6, 8 and 10 on
64-bit Windows, OS X and Linux platforms. 64-bit Windows, OS X and Linux platforms.
Sharp will be built from source at install time when: Sharp will be built from source at install time when:
@ -27,7 +27,7 @@ Sharp will be built from source at install time when:
Building from source requires: Building from source requires:
* C++11 compatible compiler such as gcc 4.8+, clang 3.0+ or MSVC 2013+ * C++11 compatible compiler such as gcc 4.8+, clang 3.0+ or MSVC 2013+
* [node-gyp](https://github.com/TooTallNate/node-gyp#installation) and its dependencies (includes Python) * [node-gyp](https://github.com/nodejs/node-gyp#installation) and its dependencies (includes Python 2.7)
## libvips ## libvips
@ -36,13 +36,14 @@ Building from source requires:
[![Ubuntu 16.04 Build Status](https://travis-ci.org/lovell/sharp.png?branch=master)](https://travis-ci.org/lovell/sharp) [![Ubuntu 16.04 Build Status](https://travis-ci.org/lovell/sharp.png?branch=master)](https://travis-ci.org/lovell/sharp)
libvips and its dependencies are fetched and stored within `node_modules/sharp/vendor` during `npm install`. libvips and its dependencies are fetched and stored within `node_modules/sharp/vendor` during `npm install`.
This involves an automated HTTPS download of approximately 7MB. This involves an automated HTTPS download of approximately 8MB.
Most recent Linux-based operating systems with glibc running on x64 and ARMv6+ CPUs should "just work", e.g.: Most Linux-based (glibc, musl) operating systems running on x64 and ARMv6+ CPUs should "just work", e.g.:
* Debian 7+ * Debian 7+
* Ubuntu 14.04+ * Ubuntu 14.04+
* Centos 7+ * Centos 7+
* Alpine 3.8+ (Node 8 and 10)
* Fedora * Fedora
* openSUSE 13.2+ * openSUSE 13.2+
* Archlinux * Archlinux
@ -61,9 +62,9 @@ and `LD_LIBRARY_PATH` at runtime.
This allows the use of newer versions of libvips with older versions of sharp. This allows the use of newer versions of libvips with older versions of sharp.
For 32-bit Intel CPUs and older Linux-based operating systems such as Centos 6, For 32-bit Intel CPUs and older Linux-based operating systems such as Centos 6,
it is recommended to install a system-wide installation of libvips from source: compiling libvips from source is recommended.
https://jcupitt.github.io/libvips/install.html#building-libvips-from-a-source-tarball [https://jcupitt.github.io/libvips/install.html#building-libvips-from-a-source-tarball](https://jcupitt.github.io/libvips/install.html#building-libvips-from-a-source-tarball)
#### Alpine Linux #### Alpine Linux
@ -71,7 +72,7 @@ libvips is available in the
[testing repository](https://pkgs.alpinelinux.org/packages?name=vips-dev): [testing repository](https://pkgs.alpinelinux.org/packages?name=vips-dev):
```sh ```sh
apk add vips-dev fftw-dev --update-cache --repository https://dl-3.alpinelinux.org/alpine/edge/testing/ apk add vips-dev fftw-dev build-base --update-cache --repository https://dl-3.alpinelinux.org/alpine/edge/testing/
``` ```
The smaller stack size of musl libc means The smaller stack size of musl libc means
@ -94,7 +95,7 @@ that it can be located using `pkg-config --modversion vips-cpp`.
[![Windows x64 Build Status](https://ci.appveyor.com/api/projects/status/pgtul704nkhhg6sg)](https://ci.appveyor.com/project/lovell/sharp) [![Windows x64 Build Status](https://ci.appveyor.com/api/projects/status/pgtul704nkhhg6sg)](https://ci.appveyor.com/project/lovell/sharp)
libvips and its dependencies are fetched and stored within `node_modules\sharp\vendor` during `npm install`. libvips and its dependencies are fetched and stored within `node_modules\sharp\vendor` during `npm install`.
This involves an automated HTTPS download of approximately 12MB. This involves an automated HTTPS download of approximately 13MB.
Only 64-bit (x64) `node.exe` is supported. Only 64-bit (x64) `node.exe` is supported.
@ -117,9 +118,6 @@ https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=193528
### Heroku ### Heroku
libvips and its dependencies are fetched and stored within `node_modules\sharp\vendor` during `npm install`.
This involves an automated HTTPS download of approximately 7MB.
Set [NODE_MODULES_CACHE](https://devcenter.heroku.com/articles/nodejs-support#cache-behavior) Set [NODE_MODULES_CACHE](https://devcenter.heroku.com/articles/nodejs-support#cache-behavior)
to `false` when using the `yarn` package manager. to `false` when using the `yarn` package manager.
@ -154,12 +152,13 @@ can be built using Docker.
```sh ```sh
rm -rf node_modules/sharp rm -rf node_modules/sharp
docker run -v "$PWD":/var/task lambci/lambda:build-nodejs6.10 npm install docker run -v "$PWD":/var/task lambci/lambda:build-nodejs8.10 npm install
``` ```
Set the Lambda runtime to Node.js 6.10. Set the Lambda runtime to Node.js 8.10.
To get the best performance select the largest memory available. A 1536 MB function provides ~12x more CPU time than a 128 MB function. To get the best performance select the largest memory available.
A 1536 MB function provides ~12x more CPU time than a 128 MB function.
### NW.js ### NW.js
@ -171,7 +170,7 @@ nw-gyp rebuild --arch=x64 --target=[your nw version]
node node_modules/sharp/install/dll-copy node node_modules/sharp/install/dll-copy
``` ```
See also http://docs.nwjs.io/en/latest/For%20Users/Advanced/Use%20Native%20Node%20Modules/ [http://docs.nwjs.io/en/latest/For%20Users/Advanced/Use%20Native%20Node%20Modules/](http://docs.nwjs.io/en/latest/For%20Users/Advanced/Use%20Native%20Node%20Modules/)
### Build tools ### Build tools
@ -199,28 +198,6 @@ and [Valgrind](http://valgrind.org/) have been used to test
the most popular web-based formats, as well as libvips itself, the most popular web-based formats, as well as libvips itself,
you are advised to perform your own testing and sandboxing. you are advised to perform your own testing and sandboxing.
ImageMagick in particular has a relatively large attack surface,
which can be partially mitigated with a
[policy.xml](http://www.imagemagick.org/script/resources.php)
configuration file to prevent the use of coders known to be vulnerable.
```xml
<policymap>
<policy domain="coder" rights="none" pattern="EPHEMERAL" />
<policy domain="coder" rights="none" pattern="URL" />
<policy domain="coder" rights="none" pattern="HTTPS" />
<policy domain="coder" rights="none" pattern="MVG" />
<policy domain="coder" rights="none" pattern="MSL" />
<policy domain="coder" rights="none" pattern="TEXT" />
<policy domain="coder" rights="none" pattern="SHOW" />
<policy domain="coder" rights="none" pattern="WIN" />
<policy domain="coder" rights="none" pattern="PLT" />
</policymap>
```
Set the `MAGICK_CONFIGURE_PATH` environment variable
to the directory containing the `policy.xml` file.
### Pre-compiled libvips binaries ### Pre-compiled libvips binaries
This module will attempt to download a pre-compiled bundle of libvips This module will attempt to download a pre-compiled bundle of libvips
@ -236,7 +213,8 @@ SHARP_IGNORE_GLOBAL_LIBVIPS=1 npm install sharp
``` ```
Should you need to manually download and inspect these files, Should you need to manually download and inspect these files,
you can do so via https://github.com/lovell/sharp-libvips/releases you can do so via
[https://github.com/lovell/sharp-libvips/releases](https://github.com/lovell/sharp-libvips/releases)
Should you wish to install these from your own location, Should you wish to install these from your own location,
set the `SHARP_DIST_BASE_URL` environment variable, e.g. set the `SHARP_DIST_BASE_URL` environment variable, e.g.
@ -265,6 +243,8 @@ Use of libraries under the terms of the LGPLv3 is via the
| expat | MIT Licence | | expat | MIT Licence |
| fontconfig | [fontconfig Licence](https://cgit.freedesktop.org/fontconfig/tree/COPYING) (BSD-like) | | fontconfig | [fontconfig Licence](https://cgit.freedesktop.org/fontconfig/tree/COPYING) (BSD-like) |
| freetype | [freetype Licence](http://git.savannah.gnu.org/cgit/freetype/freetype2.git/tree/docs/FTL.TXT) (BSD-like) | | freetype | [freetype Licence](http://git.savannah.gnu.org/cgit/freetype/freetype2.git/tree/docs/FTL.TXT) (BSD-like) |
| fribidi | LGPLv3 |
| gettext | LGPLv3 |
| giflib | MIT Licence | | giflib | MIT Licence |
| glib | LGPLv3 | | glib | LGPLv3 |
| harfbuzz | MIT Licence | | harfbuzz | MIT Licence |

View File

@ -54,9 +54,6 @@ try {
if (platformAndArch === 'freebsd-x64') { if (platformAndArch === 'freebsd-x64') {
throw new Error(`FreeBSD systems require manual installation of libvips >= ${minimumLibvipsVersion}`); throw new Error(`FreeBSD systems require manual installation of libvips >= ${minimumLibvipsVersion}`);
} }
if (detectLibc.isNonGlibcLinux) {
throw new Error(`Use with ${detectLibc.family} libc requires manual installation of libvips >= ${minimumLibvipsVersion}`);
}
if (detectLibc.family === detectLibc.GLIBC && detectLibc.version && semver.lt(`${detectLibc.version}.0`, '2.13.0')) { if (detectLibc.family === detectLibc.GLIBC && detectLibc.version && semver.lt(`${detectLibc.version}.0`, '2.13.0')) {
throw new Error(`Use with glibc version ${detectLibc.version} requires manual installation of libvips >= ${minimumLibvipsVersion}`); throw new Error(`Use with glibc version ${detectLibc.version} requires manual installation of libvips >= ${minimumLibvipsVersion}`);
} }

View File

@ -44,10 +44,16 @@ const globalLibvipsVersion = function () {
const hasVendoredLibvips = function () { const hasVendoredLibvips = function () {
const currentPlatformId = platform(); const currentPlatformId = platform();
const vendorPath = path.join(__dirname, '..', 'vendor');
let vendorVersionId;
let vendorPlatformId; let vendorPlatformId;
try { try {
vendorPlatformId = require(path.join(__dirname, '..', 'vendor', 'platform.json')); vendorVersionId = require(path.join(vendorPath, 'versions.json')).vips;
vendorPlatformId = require(path.join(vendorPath, 'platform.json'));
} catch (err) {} } catch (err) {}
if (vendorVersionId && vendorVersionId !== minimumLibvipsVersion) {
throw new Error(`Found vendored libvips v${vendorVersionId} but require v${minimumLibvipsVersion}. Please remove the 'node_modules/sharp/vendor' directory and run 'npm install'.`);
}
if (vendorPlatformId) { if (vendorPlatformId) {
if (currentPlatformId === vendorPlatformId) { if (currentPlatformId === vendorPlatformId) {
return true; return true;

View File

@ -1,10 +1,13 @@
'use strict'; 'use strict';
const detectLibc = require('detect-libc');
module.exports = function () { module.exports = function () {
const arch = process.env.npm_config_arch || process.arch; const arch = process.env.npm_config_arch || process.arch;
const platform = process.env.npm_config_platform || process.platform; const platform = process.env.npm_config_platform || process.platform;
const libc = (platform === 'linux' && detectLibc.isNonGlibcLinux) ? detectLibc.family : '';
const platformId = [platform]; const platformId = [`${platform}${libc}`];
if (arch === 'arm' || arch === 'armhf' || arch === 'arm64') { if (arch === 'arm' || arch === 'armhf' || arch === 'arm64') {
const armVersion = (arch === 'arm64') ? '8' : process.env.npm_config_armv || process.config.variables.arm_version || '6'; const armVersion = (arch === 'arm64') ? '8' : process.env.npm_config_armv || process.config.variables.arm_version || '6';
platformId.push(`armv${armVersion}`); platformId.push(`armv${armVersion}`);

View File

@ -58,7 +58,7 @@
], ],
"scripts": { "scripts": {
"install": "(node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)", "install": "(node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)",
"clean": "rm -rf node_modules/ build/ vendor/ coverage/ test/fixtures/output.*", "clean": "rm -rf node_modules/ build/ vendor/ .nyc_output/ coverage/ test/fixtures/output.*",
"test": "semistandard && cc && nyc --reporter=lcov --branches=99 mocha --slow=5000 --timeout=60000 ./test/unit/*.js && prebuild-ci", "test": "semistandard && cc && nyc --reporter=lcov --branches=99 mocha --slow=5000 --timeout=60000 ./test/unit/*.js && prebuild-ci",
"coverage": "./test/coverage/report.sh", "coverage": "./test/coverage/report.sh",
"test-leak": "./test/leak/leak.sh", "test-leak": "./test/leak/leak.sh",
@ -91,9 +91,9 @@
"nan": "^2.11.0", "nan": "^2.11.0",
"fs-copy-file-sync": "^1.1.1", "fs-copy-file-sync": "^1.1.1",
"npmlog": "^4.1.2", "npmlog": "^4.1.2",
"prebuild-install": "^4.0.0", "prebuild-install": "^5.0.0",
"semver": "^5.5.1", "semver": "^5.5.1",
"simple-get": "^2.8.1", "simple-get": "^3.0.3",
"tar": "^4.4.6", "tar": "^4.4.6",
"tunnel-agent": "^0.6.0" "tunnel-agent": "^0.6.0"
}, },
@ -105,19 +105,19 @@
"exif-reader": "^1.0.2", "exif-reader": "^1.0.2",
"icc": "^1.0.0", "icc": "^1.0.0",
"mocha": "^5.2.0", "mocha": "^5.2.0",
"mock-fs": "^4.6.0", "mock-fs": "^4.7.0",
"nyc": "^12.0.1", "nyc": "^13.1.0",
"prebuild": "^7.6.2", "prebuild": "^8.0.1",
"prebuild-ci": "^2.2.3", "prebuild-ci": "^2.2.3",
"rimraf": "^2.6.2", "rimraf": "^2.6.2",
"semistandard": "^12.0.1" "semistandard": "^12.0.1"
}, },
"license": "Apache-2.0", "license": "Apache-2.0",
"config": { "config": {
"libvips": "8.6.1" "libvips": "8.7.0"
}, },
"engines": { "engines": {
"node": ">=4.5.0" "node": ">=6"
}, },
"semistandard": { "semistandard": {
"env": [ "env": [

View File

@ -370,10 +370,6 @@ namespace sharp {
if (image.width() > 65535 || image.height() > 65535) { if (image.width() > 65535 || image.height() > 65535) {
throw vips::VError("Processed image is too large for the JPEG format"); throw vips::VError("Processed image is too large for the JPEG format");
} }
} else if (imageType == ImageType::PNG) {
if (image.width() > 2147483647 || image.height() > 2147483647) {
throw vips::VError("Processed image is too large for the PNG format");
}
} else if (imageType == ImageType::WEBP) { } else if (imageType == ImageType::WEBP) {
if (image.width() > 16383 || image.height() > 16383) { if (image.width() > 16383 || image.height() > 16383) {
throw vips::VError("Processed image is too large for the WebP format"); throw vips::VError("Processed image is too large for the WebP format");

View File

@ -613,7 +613,7 @@ VImage::new_matrixv( int width, int height, ... )
} }
VImage VImage
VImage::write( VImage out ) VImage::write( VImage out ) const
{ {
if( vips_image_write( this->get_image(), out.get_image() ) ) if( vips_image_write( this->get_image(), out.get_image() ) )
throw VError(); throw VError();
@ -622,7 +622,7 @@ VImage::write( VImage out )
} }
void void
VImage::write_to_file( const char *name, VOption *options ) VImage::write_to_file( const char *name, VOption *options ) const
{ {
char filename[VIPS_PATH_MAX]; char filename[VIPS_PATH_MAX];
char option_string[VIPS_PATH_MAX]; char option_string[VIPS_PATH_MAX];
@ -642,7 +642,7 @@ VImage::write_to_file( const char *name, VOption *options )
void void
VImage::write_to_buffer( const char *suffix, void **buf, size_t *size, VImage::write_to_buffer( const char *suffix, void **buf, size_t *size,
VOption *options ) VOption *options ) const
{ {
char filename[VIPS_PATH_MAX]; char filename[VIPS_PATH_MAX];
char option_string[VIPS_PATH_MAX]; char option_string[VIPS_PATH_MAX];
@ -675,7 +675,7 @@ VImage::write_to_buffer( const char *suffix, void **buf, size_t *size,
#include "vips-operators.cpp" #include "vips-operators.cpp"
std::vector<VImage> std::vector<VImage>
VImage::bandsplit( VOption *options ) VImage::bandsplit( VOption *options ) const
{ {
std::vector<VImage> b; std::vector<VImage> b;
@ -686,7 +686,7 @@ VImage::bandsplit( VOption *options )
} }
VImage VImage
VImage::bandjoin( VImage other, VOption *options ) VImage::bandjoin( VImage other, VOption *options ) const
{ {
VImage v[2] = { *this, other }; VImage v[2] = { *this, other };
std::vector<VImage> vec( v, v + VIPS_NUMBER( v ) ); std::vector<VImage> vec( v, v + VIPS_NUMBER( v ) );
@ -695,7 +695,7 @@ VImage::bandjoin( VImage other, VOption *options )
} }
VImage VImage
VImage::composite( VImage other, VipsBlendMode mode, VOption *options ) VImage::composite( VImage other, VipsBlendMode mode, VOption *options ) const
{ {
VImage v[2] = { *this, other }; VImage v[2] = { *this, other };
std::vector<VImage> ivec( v, v + VIPS_NUMBER( v ) ); std::vector<VImage> ivec( v, v + VIPS_NUMBER( v ) );
@ -706,7 +706,7 @@ VImage::composite( VImage other, VipsBlendMode mode, VOption *options )
} }
std::complex<double> std::complex<double>
VImage::minpos( VOption *options ) VImage::minpos( VOption *options ) const
{ {
double x, y; double x, y;
@ -719,7 +719,7 @@ VImage::minpos( VOption *options )
} }
std::complex<double> std::complex<double>
VImage::maxpos( VOption *options ) VImage::maxpos( VOption *options ) const
{ {
double x, y; double x, y;
@ -734,43 +734,43 @@ VImage::maxpos( VOption *options )
// Operator overloads // Operator overloads
VImage VImage
VImage::operator[]( int index ) VImage::operator[]( int index ) const
{ {
return( this->extract_band( index ) ); return( this->extract_band( index ) );
} }
std::vector<double> std::vector<double>
VImage::operator()( int x, int y ) VImage::operator()( int x, int y ) const
{ {
return( this->getpoint( x, y ) ); return( this->getpoint( x, y ) );
} }
VImage VImage
operator+( VImage a, VImage b ) operator+( const VImage a, const VImage b )
{ {
return( a.add( b ) ); return( a.add( b ) );
} }
VImage VImage
operator+( double a, VImage b ) operator+( double a, const VImage b )
{ {
return( b.linear( 1.0, a ) ); return( b.linear( 1.0, a ) );
} }
VImage VImage
operator+( VImage a, double b ) operator+( const VImage a, double b )
{ {
return( a.linear( 1.0, b ) ); return( a.linear( 1.0, b ) );
} }
VImage VImage
operator+( std::vector<double> a, VImage b ) operator+( const std::vector<double> a, const VImage b )
{ {
return( b.linear( 1.0, a ) ); return( b.linear( 1.0, a ) );
} }
VImage VImage
operator+( VImage a, std::vector<double> b ) operator+( const VImage a, const std::vector<double> b )
{ {
return( a.linear( 1.0, b ) ); return( a.linear( 1.0, b ) );
} }
@ -788,37 +788,37 @@ operator+=( VImage &a, const double b )
} }
VImage & VImage &
operator+=( VImage &a, std::vector<double> b ) operator+=( VImage &a, const std::vector<double> b )
{ {
return( a = a + b ); return( a = a + b );
} }
VImage VImage
operator-( VImage a, VImage b ) operator-( const VImage a, const VImage b )
{ {
return( a.subtract( b ) ); return( a.subtract( b ) );
} }
VImage VImage
operator-( double a, VImage b ) operator-( double a, const VImage b )
{ {
return( b.linear( -1.0, a ) ); return( b.linear( -1.0, a ) );
} }
VImage VImage
operator-( VImage a, double b ) operator-( const VImage a, double b )
{ {
return( a.linear( 1.0, -b ) ); return( a.linear( 1.0, -b ) );
} }
VImage VImage
operator-( std::vector<double> a, VImage b ) operator-( const std::vector<double> a, const VImage b )
{ {
return( b.linear( -1.0, a ) ); return( b.linear( -1.0, a ) );
} }
VImage VImage
operator-( VImage a, std::vector<double> b ) operator-( const VImage a, const std::vector<double> b )
{ {
return( a.linear( 1.0, vips::negate( b ) ) ); return( a.linear( 1.0, vips::negate( b ) ) );
} }
@ -836,43 +836,43 @@ operator-=( VImage &a, const double b )
} }
VImage & VImage &
operator-=( VImage &a, std::vector<double> b ) operator-=( VImage &a, const std::vector<double> b )
{ {
return( a = a - b ); return( a = a - b );
} }
VImage VImage
operator-( VImage a ) operator-( const VImage a )
{ {
return( a * -1 ); return( a * -1 );
} }
VImage VImage
operator*( VImage a, VImage b ) operator*( const VImage a, const VImage b )
{ {
return( a.multiply( b ) ); return( a.multiply( b ) );
} }
VImage VImage
operator*( double a, VImage b ) operator*( double a, const VImage b )
{ {
return( b.linear( a, 0.0 ) ); return( b.linear( a, 0.0 ) );
} }
VImage VImage
operator*( VImage a, double b ) operator*( const VImage a, double b )
{ {
return( a.linear( b, 0.0 ) ); return( a.linear( b, 0.0 ) );
} }
VImage VImage
operator*( std::vector<double> a, VImage b ) operator*( const std::vector<double> a, const VImage b )
{ {
return( b.linear( a, 0.0 ) ); return( b.linear( a, 0.0 ) );
} }
VImage VImage
operator*( VImage a, std::vector<double> b ) operator*( const VImage a, const std::vector<double> b )
{ {
return( a.linear( b, 0.0 ) ); return( a.linear( b, 0.0 ) );
} }
@ -890,37 +890,37 @@ operator*=( VImage &a, const double b )
} }
VImage & VImage &
operator*=( VImage &a, std::vector<double> b ) operator*=( VImage &a, const std::vector<double> b )
{ {
return( a = a * b ); return( a = a * b );
} }
VImage VImage
operator/( VImage a, VImage b ) operator/( const VImage a, const VImage b )
{ {
return( a.divide( b ) ); return( a.divide( b ) );
} }
VImage VImage
operator/( double a, VImage b ) operator/( double a, const VImage b )
{ {
return( b.pow( -1.0 ).linear( a, 0.0 ) ); return( b.pow( -1.0 ).linear( a, 0.0 ) );
} }
VImage VImage
operator/( VImage a, double b ) operator/( const VImage a, double b )
{ {
return( a.linear( 1.0 / b, 0.0 ) ); return( a.linear( 1.0 / b, 0.0 ) );
} }
VImage VImage
operator/( std::vector<double> a, VImage b ) operator/( const std::vector<double> a, const VImage b )
{ {
return( b.pow( -1.0 ).linear( a, 0.0 ) ); return( b.pow( -1.0 ).linear( a, 0.0 ) );
} }
VImage VImage
operator/( VImage a, std::vector<double> b ) operator/( const VImage a, const std::vector<double> b )
{ {
return( a.linear( vips::invert( b ), 0.0 ) ); return( a.linear( vips::invert( b ), 0.0 ) );
} }
@ -938,25 +938,25 @@ operator/=( VImage &a, const double b )
} }
VImage & VImage &
operator/=( VImage &a, std::vector<double> b ) operator/=( VImage &a, const std::vector<double> b )
{ {
return( a = a / b ); return( a = a / b );
} }
VImage VImage
operator%( VImage a, VImage b ) operator%( const VImage a, const VImage b )
{ {
return( a.remainder( b ) ); return( a.remainder( b ) );
} }
VImage VImage
operator%( VImage a, double b ) operator%( const VImage a, const double b )
{ {
return( a.remainder_const( to_vector( b ) ) ); return( a.remainder_const( to_vector( b ) ) );
} }
VImage VImage
operator%( VImage a, std::vector<double> b ) operator%( const VImage a, const std::vector<double> b )
{ {
return( a.remainder_const( b ) ); return( a.remainder_const( b ) );
} }
@ -974,243 +974,243 @@ operator%=( VImage &a, const double b )
} }
VImage & VImage &
operator%=( VImage &a, std::vector<double> b ) operator%=( VImage &a, const std::vector<double> b )
{ {
return( a = a % b ); return( a = a % b );
} }
VImage VImage
operator<( VImage a, VImage b ) operator<( const VImage a, const VImage b )
{ {
return( a.relational( b, VIPS_OPERATION_RELATIONAL_LESS ) ); return( a.relational( b, VIPS_OPERATION_RELATIONAL_LESS ) );
} }
VImage VImage
operator<( double a, VImage b ) operator<( const double a, const VImage b )
{ {
return( b.relational_const( VIPS_OPERATION_RELATIONAL_MORE, return( b.relational_const( VIPS_OPERATION_RELATIONAL_MORE,
to_vector( a ) ) ); to_vector( a ) ) );
} }
VImage VImage
operator<( VImage a, double b ) operator<( const VImage a, const double b )
{ {
return( a.relational_const( VIPS_OPERATION_RELATIONAL_LESS, return( a.relational_const( VIPS_OPERATION_RELATIONAL_LESS,
to_vector( b ) ) ); to_vector( b ) ) );
} }
VImage VImage
operator<( std::vector<double> a, VImage b ) operator<( const std::vector<double> a, const VImage b )
{ {
return( b.relational_const( VIPS_OPERATION_RELATIONAL_MORE, return( b.relational_const( VIPS_OPERATION_RELATIONAL_MORE,
a ) ); a ) );
} }
VImage VImage
operator<( VImage a, std::vector<double> b ) operator<( const VImage a, const std::vector<double> b )
{ {
return( a.relational_const( VIPS_OPERATION_RELATIONAL_LESS, return( a.relational_const( VIPS_OPERATION_RELATIONAL_LESS,
b ) ); b ) );
} }
VImage VImage
operator<=( VImage a, VImage b ) operator<=( const VImage a, const VImage b )
{ {
return( a.relational( b, VIPS_OPERATION_RELATIONAL_LESSEQ ) ); return( a.relational( b, VIPS_OPERATION_RELATIONAL_LESSEQ ) );
} }
VImage VImage
operator<=( double a, VImage b ) operator<=( const double a, const VImage b )
{ {
return( b.relational_const( VIPS_OPERATION_RELATIONAL_MOREEQ, return( b.relational_const( VIPS_OPERATION_RELATIONAL_MOREEQ,
to_vector( a ) ) ); to_vector( a ) ) );
} }
VImage VImage
operator<=( VImage a, double b ) operator<=( const VImage a, const double b )
{ {
return( a.relational_const( VIPS_OPERATION_RELATIONAL_LESSEQ, return( a.relational_const( VIPS_OPERATION_RELATIONAL_LESSEQ,
to_vector( b ) ) ); to_vector( b ) ) );
} }
VImage VImage
operator<=( std::vector<double> a, VImage b ) operator<=( const std::vector<double> a, const VImage b )
{ {
return( b.relational_const( VIPS_OPERATION_RELATIONAL_MOREEQ, return( b.relational_const( VIPS_OPERATION_RELATIONAL_MOREEQ,
a ) ); a ) );
} }
VImage VImage
operator<=( VImage a, std::vector<double> b ) operator<=( const VImage a, const std::vector<double> b )
{ {
return( a.relational_const( VIPS_OPERATION_RELATIONAL_LESSEQ, return( a.relational_const( VIPS_OPERATION_RELATIONAL_LESSEQ,
b ) ); b ) );
} }
VImage VImage
operator>( VImage a, VImage b ) operator>( const VImage a, const VImage b )
{ {
return( a.relational( b, VIPS_OPERATION_RELATIONAL_MORE ) ); return( a.relational( b, VIPS_OPERATION_RELATIONAL_MORE ) );
} }
VImage VImage
operator>( double a, VImage b ) operator>( const double a, const VImage b )
{ {
return( b.relational_const( VIPS_OPERATION_RELATIONAL_LESS, return( b.relational_const( VIPS_OPERATION_RELATIONAL_LESS,
to_vector( a ) ) ); to_vector( a ) ) );
} }
VImage VImage
operator>( VImage a, double b ) operator>( const VImage a, const double b )
{ {
return( a.relational_const( VIPS_OPERATION_RELATIONAL_MORE, return( a.relational_const( VIPS_OPERATION_RELATIONAL_MORE,
to_vector( b ) ) ); to_vector( b ) ) );
} }
VImage VImage
operator>( std::vector<double> a, VImage b ) operator>( const std::vector<double> a, const VImage b )
{ {
return( b.relational_const( VIPS_OPERATION_RELATIONAL_LESS, return( b.relational_const( VIPS_OPERATION_RELATIONAL_LESS,
a ) ); a ) );
} }
VImage VImage
operator>( VImage a, std::vector<double> b ) operator>( const VImage a, const std::vector<double> b )
{ {
return( a.relational_const( VIPS_OPERATION_RELATIONAL_MORE, return( a.relational_const( VIPS_OPERATION_RELATIONAL_MORE,
b ) ); b ) );
} }
VImage VImage
operator>=( VImage a, VImage b ) operator>=( const VImage a, const VImage b )
{ {
return( a.relational( b, VIPS_OPERATION_RELATIONAL_MOREEQ ) ); return( a.relational( b, VIPS_OPERATION_RELATIONAL_MOREEQ ) );
} }
VImage VImage
operator>=( double a, VImage b ) operator>=( const double a, const VImage b )
{ {
return( b.relational_const( VIPS_OPERATION_RELATIONAL_LESSEQ, return( b.relational_const( VIPS_OPERATION_RELATIONAL_LESSEQ,
to_vector( a ) ) ); to_vector( a ) ) );
} }
VImage VImage
operator>=( VImage a, double b ) operator>=( const VImage a, const double b )
{ {
return( a.relational_const( VIPS_OPERATION_RELATIONAL_MOREEQ, return( a.relational_const( VIPS_OPERATION_RELATIONAL_MOREEQ,
to_vector( b ) ) ); to_vector( b ) ) );
} }
VImage VImage
operator>=( std::vector<double> a, VImage b ) operator>=( const std::vector<double> a, const VImage b )
{ {
return( b.relational_const( VIPS_OPERATION_RELATIONAL_LESSEQ, return( b.relational_const( VIPS_OPERATION_RELATIONAL_LESSEQ,
a ) ); a ) );
} }
VImage VImage
operator>=( VImage a, std::vector<double> b ) operator>=( const VImage a, const std::vector<double> b )
{ {
return( a.relational_const( VIPS_OPERATION_RELATIONAL_MOREEQ, return( a.relational_const( VIPS_OPERATION_RELATIONAL_MOREEQ,
b ) ); b ) );
} }
VImage VImage
operator==( VImage a, VImage b ) operator==( const VImage a, const VImage b )
{ {
return( a.relational( b, VIPS_OPERATION_RELATIONAL_EQUAL ) ); return( a.relational( b, VIPS_OPERATION_RELATIONAL_EQUAL ) );
} }
VImage VImage
operator==( double a, VImage b ) operator==( const double a, const VImage b )
{ {
return( b.relational_const( VIPS_OPERATION_RELATIONAL_EQUAL, return( b.relational_const( VIPS_OPERATION_RELATIONAL_EQUAL,
to_vector( a ) ) ); to_vector( a ) ) );
} }
VImage VImage
operator==( VImage a, double b ) operator==( const VImage a, const double b )
{ {
return( a.relational_const( VIPS_OPERATION_RELATIONAL_EQUAL, return( a.relational_const( VIPS_OPERATION_RELATIONAL_EQUAL,
to_vector( b ) ) ); to_vector( b ) ) );
} }
VImage VImage
operator==( std::vector<double> a, VImage b ) operator==( const std::vector<double> a, const VImage b )
{ {
return( b.relational_const( VIPS_OPERATION_RELATIONAL_EQUAL, return( b.relational_const( VIPS_OPERATION_RELATIONAL_EQUAL,
a ) ); a ) );
} }
VImage VImage
operator==( VImage a, std::vector<double> b ) operator==( const VImage a, const std::vector<double> b )
{ {
return( a.relational_const( VIPS_OPERATION_RELATIONAL_EQUAL, return( a.relational_const( VIPS_OPERATION_RELATIONAL_EQUAL,
b ) ); b ) );
} }
VImage VImage
operator!=( VImage a, VImage b ) operator!=( const VImage a, const VImage b )
{ {
return( a.relational( b, VIPS_OPERATION_RELATIONAL_NOTEQ ) ); return( a.relational( b, VIPS_OPERATION_RELATIONAL_NOTEQ ) );
} }
VImage VImage
operator!=( double a, VImage b ) operator!=( const double a, const VImage b )
{ {
return( b.relational_const( VIPS_OPERATION_RELATIONAL_NOTEQ, return( b.relational_const( VIPS_OPERATION_RELATIONAL_NOTEQ,
to_vector( a ) ) ); to_vector( a ) ) );
} }
VImage VImage
operator!=( VImage a, double b ) operator!=( const VImage a, const double b )
{ {
return( a.relational_const( VIPS_OPERATION_RELATIONAL_NOTEQ, return( a.relational_const( VIPS_OPERATION_RELATIONAL_NOTEQ,
to_vector( b ) ) ); to_vector( b ) ) );
} }
VImage VImage
operator!=( std::vector<double> a, VImage b ) operator!=( const std::vector<double> a, const VImage b )
{ {
return( b.relational_const( VIPS_OPERATION_RELATIONAL_NOTEQ, return( b.relational_const( VIPS_OPERATION_RELATIONAL_NOTEQ,
a ) ); a ) );
} }
VImage VImage
operator!=( VImage a, std::vector<double> b ) operator!=( const VImage a, const std::vector<double> b )
{ {
return( a.relational_const( VIPS_OPERATION_RELATIONAL_NOTEQ, return( a.relational_const( VIPS_OPERATION_RELATIONAL_NOTEQ,
b ) ); b ) );
} }
VImage VImage
operator&( VImage a, VImage b ) operator&( const VImage a, const VImage b )
{ {
return( a.boolean( b, VIPS_OPERATION_BOOLEAN_AND ) ); return( a.boolean( b, VIPS_OPERATION_BOOLEAN_AND ) );
} }
VImage VImage
operator&( double a, VImage b ) operator&( const double a, const VImage b )
{ {
return( b.boolean_const( VIPS_OPERATION_BOOLEAN_AND, return( b.boolean_const( VIPS_OPERATION_BOOLEAN_AND,
to_vector( a ) ) ); to_vector( a ) ) );
} }
VImage VImage
operator&( VImage a, double b ) operator&( const VImage a, const double b )
{ {
return( a.boolean_const( VIPS_OPERATION_BOOLEAN_AND, return( a.boolean_const( VIPS_OPERATION_BOOLEAN_AND,
to_vector( b ) ) ); to_vector( b ) ) );
} }
VImage VImage
operator&( std::vector<double> a, VImage b ) operator&( const std::vector<double> a, const VImage b )
{ {
return( b.boolean_const( VIPS_OPERATION_BOOLEAN_AND, a ) ); return( b.boolean_const( VIPS_OPERATION_BOOLEAN_AND, a ) );
} }
VImage VImage
operator&( VImage a, std::vector<double> b ) operator&( const VImage a, const std::vector<double> b )
{ {
return( a.boolean_const( VIPS_OPERATION_BOOLEAN_AND, b ) ); return( a.boolean_const( VIPS_OPERATION_BOOLEAN_AND, b ) );
} }
@ -1228,40 +1228,40 @@ operator&=( VImage &a, const double b )
} }
VImage & VImage &
operator&=( VImage &a, std::vector<double> b ) operator&=( VImage &a, const std::vector<double> b )
{ {
return( a = a & b ); return( a = a & b );
} }
VImage VImage
operator|( VImage a, VImage b ) operator|( const VImage a, const VImage b )
{ {
return( a.boolean( b, VIPS_OPERATION_BOOLEAN_OR ) ); return( a.boolean( b, VIPS_OPERATION_BOOLEAN_OR ) );
} }
VImage VImage
operator|( double a, VImage b ) operator|( const double a, const VImage b )
{ {
return( b.boolean_const( VIPS_OPERATION_BOOLEAN_OR, return( b.boolean_const( VIPS_OPERATION_BOOLEAN_OR,
to_vector( a ) ) ); to_vector( a ) ) );
} }
VImage VImage
operator|( VImage a, double b ) operator|( const VImage a, const double b )
{ {
return( a.boolean_const( VIPS_OPERATION_BOOLEAN_OR, return( a.boolean_const( VIPS_OPERATION_BOOLEAN_OR,
to_vector( b ) ) ); to_vector( b ) ) );
} }
VImage VImage
operator|( std::vector<double> a, VImage b ) operator|( const std::vector<double> a, const VImage b )
{ {
return( b.boolean_const( VIPS_OPERATION_BOOLEAN_OR, return( b.boolean_const( VIPS_OPERATION_BOOLEAN_OR,
a ) ); a ) );
} }
VImage VImage
operator|( VImage a, std::vector<double> b ) operator|( const VImage a, const std::vector<double> b )
{ {
return( a.boolean_const( VIPS_OPERATION_BOOLEAN_OR, return( a.boolean_const( VIPS_OPERATION_BOOLEAN_OR,
b ) ); b ) );
@ -1280,40 +1280,40 @@ operator|=( VImage &a, const double b )
} }
VImage & VImage &
operator|=( VImage &a, std::vector<double> b ) operator|=( VImage &a, const std::vector<double> b )
{ {
return( a = a | b ); return( a = a | b );
} }
VImage VImage
operator^( VImage a, VImage b ) operator^( const VImage a, const VImage b )
{ {
return( a.boolean( b, VIPS_OPERATION_BOOLEAN_EOR ) ); return( a.boolean( b, VIPS_OPERATION_BOOLEAN_EOR ) );
} }
VImage VImage
operator^( double a, VImage b ) operator^( const double a, const VImage b )
{ {
return( b.boolean_const( VIPS_OPERATION_BOOLEAN_EOR, return( b.boolean_const( VIPS_OPERATION_BOOLEAN_EOR,
to_vector( a ) ) ); to_vector( a ) ) );
} }
VImage VImage
operator^( VImage a, double b ) operator^( const VImage a, const double b )
{ {
return( a.boolean_const( VIPS_OPERATION_BOOLEAN_EOR, return( a.boolean_const( VIPS_OPERATION_BOOLEAN_EOR,
to_vector( b ) ) ); to_vector( b ) ) );
} }
VImage VImage
operator^( std::vector<double> a, VImage b ) operator^( const std::vector<double> a, const VImage b )
{ {
return( b.boolean_const( VIPS_OPERATION_BOOLEAN_EOR, return( b.boolean_const( VIPS_OPERATION_BOOLEAN_EOR,
a ) ); a ) );
} }
VImage VImage
operator^( VImage a, std::vector<double> b ) operator^( const VImage a, const std::vector<double> b )
{ {
return( a.boolean_const( VIPS_OPERATION_BOOLEAN_EOR, return( a.boolean_const( VIPS_OPERATION_BOOLEAN_EOR,
b ) ); b ) );
@ -1332,26 +1332,26 @@ operator^=( VImage &a, const double b )
} }
VImage & VImage &
operator^=( VImage &a, std::vector<double> b ) operator^=( VImage &a, const std::vector<double> b )
{ {
return( a = a ^ b ); return( a = a ^ b );
} }
VImage VImage
operator<<( VImage a, VImage b ) operator<<( const VImage a, const VImage b )
{ {
return( a.boolean( b, VIPS_OPERATION_BOOLEAN_LSHIFT ) ); return( a.boolean( b, VIPS_OPERATION_BOOLEAN_LSHIFT ) );
} }
VImage VImage
operator<<( VImage a, double b ) operator<<( const VImage a, const double b )
{ {
return( a.boolean_const( VIPS_OPERATION_BOOLEAN_LSHIFT, return( a.boolean_const( VIPS_OPERATION_BOOLEAN_LSHIFT,
to_vector( b ) ) ); to_vector( b ) ) );
} }
VImage VImage
operator<<( VImage a, std::vector<double> b ) operator<<( const VImage a, const std::vector<double> b )
{ {
return( a.boolean_const( VIPS_OPERATION_BOOLEAN_LSHIFT, return( a.boolean_const( VIPS_OPERATION_BOOLEAN_LSHIFT,
b ) ); b ) );
@ -1370,26 +1370,26 @@ operator<<=( VImage &a, const double b )
} }
VImage & VImage &
operator<<=( VImage &a, std::vector<double> b ) operator<<=( VImage &a, const std::vector<double> b )
{ {
return( a = a << b ); return( a = a << b );
} }
VImage VImage
operator>>( VImage a, VImage b ) operator>>( const VImage a, const VImage b )
{ {
return( a.boolean( b, VIPS_OPERATION_BOOLEAN_RSHIFT ) ); return( a.boolean( b, VIPS_OPERATION_BOOLEAN_RSHIFT ) );
} }
VImage VImage
operator>>( VImage a, double b ) operator>>( const VImage a, const double b )
{ {
return( a.boolean_const( VIPS_OPERATION_BOOLEAN_RSHIFT, return( a.boolean_const( VIPS_OPERATION_BOOLEAN_RSHIFT,
to_vector( b ) ) ); to_vector( b ) ) );
} }
VImage VImage
operator>>( VImage a, std::vector<double> b ) operator>>( const VImage a, const std::vector<double> b )
{ {
return( a.boolean_const( VIPS_OPERATION_BOOLEAN_RSHIFT, return( a.boolean_const( VIPS_OPERATION_BOOLEAN_RSHIFT,
b ) ); b ) );
@ -1408,7 +1408,7 @@ operator>>=( VImage &a, const double b )
} }
VImage & VImage &
operator>>=( VImage &a, std::vector<double> b ) operator>>=( VImage &a, const std::vector<double> b )
{ {
return( a = a << b ); return( a = a << b );
} }

File diff suppressed because it is too large Load Diff

View File

@ -894,10 +894,6 @@ class PipelineWorker : public Nan::AsyncWorker {
if (baton->tiffCompression == VIPS_FOREIGN_TIFF_COMPRESSION_JPEG) { if (baton->tiffCompression == VIPS_FOREIGN_TIFF_COMPRESSION_JPEG) {
sharp::AssertImageTypeDimensions(image, ImageType::JPEG); sharp::AssertImageTypeDimensions(image, ImageType::JPEG);
} }
// Cast pixel values to float, if required
if (baton->tiffPredictor == VIPS_FOREIGN_TIFF_PREDICTOR_FLOAT) {
image = image.cast(VIPS_FORMAT_FLOAT);
}
image.tiffsave(const_cast<char*>(baton->fileOut.data()), VImage::option() image.tiffsave(const_cast<char*>(baton->fileOut.data()), VImage::option()
->set("strip", !baton->withMetadata) ->set("strip", !baton->withMetadata)
->set("Q", baton->tiffQuality) ->set("Q", baton->tiffQuality)

View File

@ -259,7 +259,7 @@ NAN_METHOD(_maxColourDistance) {
} }
// Calculate colour distance // Calculate colour distance
maxColourDistance = image1.dE00(image2).max(); maxColourDistance = image1.dE00(image2).max();
} catch (VError err) { } catch (VError const &err) {
return ThrowError(err.what()); return ThrowError(err.what());
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 258 B

After

Width:  |  Height:  |  Size: 270 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 263 B

After

Width:  |  Height:  |  Size: 265 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

View File

@ -1,9 +1,10 @@
'use strict'; 'use strict';
const detectLibc = require('detect-libc');
const sharp = require('../../'); const sharp = require('../../');
// Define SHARP_TEST_WITHOUT_CACHE environment variable to prevent use of libvips' cache const usingCache = detectLibc.family !== detectLibc.MUSL;
beforeEach(function () { beforeEach(function () {
sharp.cache(!process.env.SHARP_TEST_WITHOUT_CACHE); sharp.cache(usingCache);
}); });

View File

@ -2,6 +2,7 @@
const fs = require('fs'); const fs = require('fs');
const assert = require('assert'); const assert = require('assert');
const rimraf = require('rimraf');
const sharp = require('../../'); const sharp = require('../../');
const fixtures = require('../fixtures'); const fixtures = require('../fixtures');
@ -16,7 +17,7 @@ describe('Input/output', function () {
it('Read from File and write to Stream', function (done) { it('Read from File and write to Stream', function (done) {
const writable = fs.createWriteStream(fixtures.outputJpg); const writable = fs.createWriteStream(fixtures.outputJpg);
writable.on('finish', function () { writable.on('close', function () {
sharp(fixtures.outputJpg).toBuffer(function (err, data, info) { sharp(fixtures.outputJpg).toBuffer(function (err, data, info) {
if (err) throw err; if (err) throw err;
assert.strictEqual(true, data.length > 0); assert.strictEqual(true, data.length > 0);
@ -24,8 +25,7 @@ describe('Input/output', function () {
assert.strictEqual('jpeg', info.format); assert.strictEqual('jpeg', info.format);
assert.strictEqual(320, info.width); assert.strictEqual(320, info.width);
assert.strictEqual(240, info.height); assert.strictEqual(240, info.height);
fs.unlinkSync(fixtures.outputJpg); rimraf(fixtures.outputJpg, done);
done();
}); });
}); });
sharp(fixtures.inputJpg).resize(320, 240).pipe(writable); sharp(fixtures.inputJpg).resize(320, 240).pipe(writable);
@ -34,7 +34,7 @@ describe('Input/output', function () {
it('Read from Buffer and write to Stream', function (done) { it('Read from Buffer and write to Stream', function (done) {
const inputJpgBuffer = fs.readFileSync(fixtures.inputJpg); const inputJpgBuffer = fs.readFileSync(fixtures.inputJpg);
const writable = fs.createWriteStream(fixtures.outputJpg); const writable = fs.createWriteStream(fixtures.outputJpg);
writable.on('finish', function () { writable.on('close', function () {
sharp(fixtures.outputJpg).toBuffer(function (err, data, info) { sharp(fixtures.outputJpg).toBuffer(function (err, data, info) {
if (err) throw err; if (err) throw err;
assert.strictEqual(true, data.length > 0); assert.strictEqual(true, data.length > 0);
@ -42,8 +42,7 @@ describe('Input/output', function () {
assert.strictEqual('jpeg', info.format); assert.strictEqual('jpeg', info.format);
assert.strictEqual(320, info.width); assert.strictEqual(320, info.width);
assert.strictEqual(240, info.height); assert.strictEqual(240, info.height);
fs.unlinkSync(fixtures.outputJpg); rimraf(fixtures.outputJpg, done);
done();
}); });
}); });
sharp(inputJpgBuffer).resize(320, 240).pipe(writable); sharp(inputJpgBuffer).resize(320, 240).pipe(writable);
@ -57,8 +56,7 @@ describe('Input/output', function () {
assert.strictEqual('jpeg', info.format); assert.strictEqual('jpeg', info.format);
assert.strictEqual(320, info.width); assert.strictEqual(320, info.width);
assert.strictEqual(240, info.height); assert.strictEqual(240, info.height);
fs.unlinkSync(fixtures.outputJpg); rimraf(fixtures.outputJpg, done);
done();
}); });
readable.pipe(pipeline); readable.pipe(pipeline);
}); });
@ -134,7 +132,7 @@ describe('Input/output', function () {
it('Read from Stream and write to Stream', function (done) { it('Read from Stream and write to Stream', function (done) {
const readable = fs.createReadStream(fixtures.inputJpg); const readable = fs.createReadStream(fixtures.inputJpg);
const writable = fs.createWriteStream(fixtures.outputJpg); const writable = fs.createWriteStream(fixtures.outputJpg);
writable.on('finish', function () { writable.on('close', function () {
sharp(fixtures.outputJpg).toBuffer(function (err, data, info) { sharp(fixtures.outputJpg).toBuffer(function (err, data, info) {
if (err) throw err; if (err) throw err;
assert.strictEqual(true, data.length > 0); assert.strictEqual(true, data.length > 0);
@ -142,8 +140,7 @@ describe('Input/output', function () {
assert.strictEqual('jpeg', info.format); assert.strictEqual('jpeg', info.format);
assert.strictEqual(320, info.width); assert.strictEqual(320, info.width);
assert.strictEqual(240, info.height); assert.strictEqual(240, info.height);
fs.unlinkSync(fixtures.outputJpg); rimraf(fixtures.outputJpg, done);
done();
}); });
}); });
const pipeline = sharp().resize(320, 240); const pipeline = sharp().resize(320, 240);
@ -162,10 +159,9 @@ describe('Input/output', function () {
assert.strictEqual(3, info.channels); assert.strictEqual(3, info.channels);
infoEventEmitted = true; infoEventEmitted = true;
}); });
writable.on('finish', function () { writable.on('close', function () {
assert.strictEqual(true, infoEventEmitted); assert.strictEqual(true, infoEventEmitted);
fs.unlinkSync(fixtures.outputJpg); rimraf(fixtures.outputJpg, done);
done();
}); });
readable.pipe(pipeline).pipe(writable); readable.pipe(pipeline).pipe(writable);
}); });
@ -177,8 +173,7 @@ describe('Input/output', function () {
anErrorWasEmitted = !!err; anErrorWasEmitted = !!err;
}).on('end', function () { }).on('end', function () {
assert(anErrorWasEmitted); assert(anErrorWasEmitted);
fs.unlinkSync(fixtures.outputJpg); rimraf(fixtures.outputJpg, done);
done();
}); });
const readableButNotAnImage = fs.createReadStream(__filename); const readableButNotAnImage = fs.createReadStream(__filename);
const writable = fs.createWriteStream(fixtures.outputJpg); const writable = fs.createWriteStream(fixtures.outputJpg);
@ -192,8 +187,7 @@ describe('Input/output', function () {
anErrorWasEmitted = !!err; anErrorWasEmitted = !!err;
}).on('end', function () { }).on('end', function () {
assert(anErrorWasEmitted); assert(anErrorWasEmitted);
fs.unlinkSync(fixtures.outputJpg); rimraf(fixtures.outputJpg, done);
done();
}); });
const writable = fs.createWriteStream(fixtures.outputJpg); const writable = fs.createWriteStream(fixtures.outputJpg);
readableButNotAnImage.pipe(writable); readableButNotAnImage.pipe(writable);
@ -202,7 +196,7 @@ describe('Input/output', function () {
it('Readable side of Stream can start flowing after Writable side has finished', function (done) { it('Readable side of Stream can start flowing after Writable side has finished', function (done) {
const readable = fs.createReadStream(fixtures.inputJpg); const readable = fs.createReadStream(fixtures.inputJpg);
const writable = fs.createWriteStream(fixtures.outputJpg); const writable = fs.createWriteStream(fixtures.outputJpg);
writable.on('finish', function () { writable.on('close', function () {
sharp(fixtures.outputJpg).toBuffer(function (err, data, info) { sharp(fixtures.outputJpg).toBuffer(function (err, data, info) {
if (err) throw err; if (err) throw err;
assert.strictEqual(true, data.length > 0); assert.strictEqual(true, data.length > 0);
@ -210,8 +204,7 @@ describe('Input/output', function () {
assert.strictEqual('jpeg', info.format); assert.strictEqual('jpeg', info.format);
assert.strictEqual(320, info.width); assert.strictEqual(320, info.width);
assert.strictEqual(240, info.height); assert.strictEqual(240, info.height);
fs.unlinkSync(fixtures.outputJpg); rimraf(fixtures.outputJpg, done);
done();
}); });
}); });
const pipeline = sharp().resize(320, 240); const pipeline = sharp().resize(320, 240);
@ -564,8 +557,7 @@ describe('Input/output', function () {
assert.strictEqual('jpeg', info.format); assert.strictEqual('jpeg', info.format);
assert.strictEqual(320, info.width); assert.strictEqual(320, info.width);
assert.strictEqual(80, info.height); assert.strictEqual(80, info.height);
fs.unlinkSync(fixtures.outputZoinks); rimraf(fixtures.outputZoinks, done);
done();
}); });
}); });
@ -578,8 +570,7 @@ describe('Input/output', function () {
assert.strictEqual('png', info.format); assert.strictEqual('png', info.format);
assert.strictEqual(320, info.width); assert.strictEqual(320, info.width);
assert.strictEqual(80, info.height); assert.strictEqual(80, info.height);
fs.unlinkSync(fixtures.outputZoinks); rimraf(fixtures.outputZoinks, done);
done();
}); });
}); });
@ -592,8 +583,7 @@ describe('Input/output', function () {
assert.strictEqual('webp', info.format); assert.strictEqual('webp', info.format);
assert.strictEqual(320, info.width); assert.strictEqual(320, info.width);
assert.strictEqual(80, info.height); assert.strictEqual(80, info.height);
fs.unlinkSync(fixtures.outputZoinks); rimraf(fixtures.outputZoinks, done);
done();
}); });
}); });
@ -606,8 +596,7 @@ describe('Input/output', function () {
assert.strictEqual('tiff', info.format); assert.strictEqual('tiff', info.format);
assert.strictEqual(320, info.width); assert.strictEqual(320, info.width);
assert.strictEqual(80, info.height); assert.strictEqual(80, info.height);
fs.unlinkSync(fixtures.outputZoinks); rimraf(fixtures.outputZoinks, done);
done();
}); });
}); });
@ -620,8 +609,7 @@ describe('Input/output', function () {
assert.strictEqual('png', info.format); assert.strictEqual('png', info.format);
assert.strictEqual(320, info.width); assert.strictEqual(320, info.width);
assert.strictEqual(80, info.height); assert.strictEqual(80, info.height);
fs.unlinkSync(fixtures.outputZoinks); rimraf(fixtures.outputZoinks, done);
done();
}); });
}); });
@ -635,8 +623,7 @@ describe('Input/output', function () {
assert.strictEqual('jpeg', info.format); assert.strictEqual('jpeg', info.format);
assert.strictEqual(320, info.width); assert.strictEqual(320, info.width);
assert.strictEqual(80, info.height); assert.strictEqual(80, info.height);
fs.unlinkSync(fixtures.outputZoinks); rimraf(fixtures.outputZoinks, done);
done();
}); });
}); });
}); });
@ -1080,7 +1067,7 @@ describe('Input/output', function () {
if (err) throw err; if (err) throw err;
assert.strictEqual('tiff', info.format); assert.strictEqual('tiff', info.format);
assert(info.size === startSize); assert(info.size === startSize);
fs.unlink(fixtures.outputTiff, done); rimraf(fixtures.outputTiff, done);
}); });
}); });
@ -1097,7 +1084,7 @@ describe('Input/output', function () {
if (err) throw err; if (err) throw err;
assert.strictEqual('tiff', info.format); assert.strictEqual('tiff', info.format);
assert(info.size < (startSize / 2)); assert(info.size < (startSize / 2));
fs.unlink(fixtures.outputTiff, done); rimraf(fixtures.outputTiff, done);
}); });
}); });
@ -1120,7 +1107,7 @@ describe('Input/output', function () {
sharp(fixtures.outputTiff).metadata(function (err, metadata) { sharp(fixtures.outputTiff).metadata(function (err, metadata) {
if (err) throw err; if (err) throw err;
assert.strictEqual(metadata.density, res * 2.54); // convert to dpi assert.strictEqual(metadata.density, res * 2.54); // convert to dpi
fs.unlink(fixtures.outputTiff, done); rimraf(fixtures.outputTiff, done);
}); });
}); });
}); });
@ -1165,7 +1152,7 @@ describe('Input/output', function () {
if (err) throw err; if (err) throw err;
assert.strictEqual('tiff', info.format); assert.strictEqual('tiff', info.format);
assert(info.size < startSize); assert(info.size < startSize);
fs.unlink(fixtures.outputTiff, done); rimraf(fixtures.outputTiff, done);
}); });
}); });
@ -1181,7 +1168,7 @@ describe('Input/output', function () {
if (err) throw err; if (err) throw err;
assert.strictEqual('tiff', info.format); assert.strictEqual('tiff', info.format);
assert(info.size < startSize); assert(info.size < startSize);
fs.unlink(fixtures.outputTiff, done); rimraf(fixtures.outputTiff, done);
}); });
}); });
@ -1196,7 +1183,7 @@ describe('Input/output', function () {
if (err) throw err; if (err) throw err;
assert.strictEqual('tiff', info.format); assert.strictEqual('tiff', info.format);
assert(info.size < startSize); assert(info.size < startSize);
fs.unlink(fixtures.outputTiff, done); rimraf(fixtures.outputTiff, done);
}); });
}); });
@ -1211,7 +1198,7 @@ describe('Input/output', function () {
if (err) throw err; if (err) throw err;
assert.strictEqual('tiff', info.format); assert.strictEqual('tiff', info.format);
assert(info.size < startSize); assert(info.size < startSize);
fs.unlink(fixtures.outputTiff, done); rimraf(fixtures.outputTiff, done);
}); });
}); });
@ -1226,7 +1213,7 @@ describe('Input/output', function () {
if (err) throw err; if (err) throw err;
assert.strictEqual('tiff', info.format); assert.strictEqual('tiff', info.format);
assert(info.size < startSize); assert(info.size < startSize);
fs.unlink(fixtures.outputTiff, done); rimraf(fixtures.outputTiff, done);
}); });
}); });
@ -1240,7 +1227,7 @@ describe('Input/output', function () {
if (err) throw err; if (err) throw err;
assert.strictEqual('tiff', info.format); assert.strictEqual('tiff', info.format);
assert(info.size < startSize); assert(info.size < startSize);
fs.unlink(fixtures.outputTiff, done); rimraf(fixtures.outputTiff, done);
}); });
}); });
@ -1384,8 +1371,7 @@ describe('Input/output', function () {
assert.strictEqual('v', info.format); assert.strictEqual('v', info.format);
assert.strictEqual(70, info.width); assert.strictEqual(70, info.width);
assert.strictEqual(60, info.height); assert.strictEqual(60, info.height);
fs.unlinkSync(fixtures.outputV); rimraf(fixtures.outputV, done);
done();
}); });
}); });