Compare commits

...

15 Commits

Author SHA1 Message Date
Lovell Fuller
20e75dc50b v0.12.2 2016-01-16 11:29:23 +00:00
Lovell Fuller
d2e5441d6e Dependency version bumps 2016-01-14 18:39:29 +00:00
Lovell Fuller
0ffa1e72d0 Attempt to remove temp file after install #331 2016-01-06 16:31:01 +00:00
Lovell Fuller
a0e034a9e9 Add support for pre-compiled libvips on ARM CPUs
Uses a HypriotOS-managed docker container for this
2016-01-06 15:50:36 +00:00
Lovell Fuller
3c7cbf8685 Update libvips to v8.2.0
Plus version bumps of other dependencies
2016-01-02 14:19:46 +00:00
Lovell Fuller
7541dfcab2 Document support for FreeBSD/gmake #326 2016-01-01 16:34:18 +00:00
Lovell Fuller
dc2b79ac9a Use array context for include/library paths in gyp config
Remove -I prefix from include paths
Should allow for compilation on FreeBSD #326
2016-01-01 14:04:52 +00:00
Lovell Fuller
6d62051877 Bump minimum version of libvips to 8.1.1 #324
Debian-based systems must compile from source
2015-12-23 20:54:37 +00:00
Lovell Fuller
61b86744d7 Ensure 16-bit input images work with embed option #325 2015-12-23 20:46:49 +00:00
Lovell Fuller
fd5b4a131f v0.12.1 2015-12-12 10:21:36 +00:00
Lovell Fuller
32c4b9eff1 Allow SIMD vector unit to be toggled on/off #172
Currently defaults to off but future versions may default to on
2015-12-12 09:11:50 +00:00
Lovell Fuller
95cf35efc5 Add changelog for v0.12.1 2015-12-06 20:40:05 +00:00
Lovell Fuller
58e6368525 Ensure embedded ICC profiles output with perceptual intent #321 2015-12-06 20:24:17 +00:00
Lovell Fuller
16e0d54b15 Use the NPM-configured HTTPS proxy, if present 2015-12-03 21:30:47 +00:00
Lovell Fuller
be381e4440 Add release date for v0.12.0 2015-11-23 14:06:49 +00:00
31 changed files with 471 additions and 116 deletions

View File

@@ -1,6 +1,7 @@
build
node_modules
coverage
.editorconfig
.jshintignore
.jshintrc
.gitignore

View File

@@ -13,7 +13,7 @@ Bicubic interpolation with Lanczos anti-alias filtering ensures quality is not s
As well as image resizing, operations such as
rotation, extraction, compositing and gamma correction are available.
64-bit Windows and recent Linux systems do not require
Most Windows (x64), Linux and ARMv6+ systems do not require
the installation of any external runtime dependencies.
Use with OS X is as simple as running `brew install homebrew/science/vips`
@@ -36,7 +36,7 @@ covers reporting bugs, requesting features and submitting code changes.
### Licence
Copyright 2013, 2014, 2015 Lovell Fuller and contributors.
Copyright 2013, 2014, 2015, 2016 Lovell Fuller and contributors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.

View File

@@ -49,12 +49,12 @@
'conditions': [
['use_global_vips == "true"', {
# Use pkg-config for include and lib
'include_dirs': ['<!(PKG_CONFIG_PATH="<(pkg_config_path)" pkg-config --cflags vips glib-2.0)'],
'include_dirs': ['<!@(PKG_CONFIG_PATH="<(pkg_config_path)" pkg-config --cflags-only-I vips glib-2.0 | sed s\/-I//g)'],
'conditions': [
['runtime_link == "static"', {
'libraries': ['<!(PKG_CONFIG_PATH="<(pkg_config_path)" pkg-config --libs vips --static)']
'libraries': ['<!@(PKG_CONFIG_PATH="<(pkg_config_path)" pkg-config --libs --static vips)']
}, {
'libraries': ['<!(PKG_CONFIG_PATH="<(pkg_config_path)" pkg-config --libs vips)']
'libraries': ['<!@(PKG_CONFIG_PATH="<(pkg_config_path)" pkg-config --libs vips)']
}]
]
}, {

View File

@@ -25,7 +25,7 @@ var isFile = function(file) {
return exists;
};
var unpack = function(tarPath) {
var unpack = function(tarPath, done) {
var extractor = tar.Extract({
path: __dirname
});
@@ -34,6 +34,9 @@ var unpack = function(tarPath) {
if (!isFile(vipsHeaderPath)) {
error('Could not unpack ' + tarPath);
}
if (typeof done === 'function') {
done();
}
});
fs.createReadStream(tarPath).on('error', error)
.pipe(zlib.Unzip())
@@ -54,9 +57,9 @@ var error = function(msg) {
module.exports.download_vips = function() {
// Has vips been installed locally?
if (!isFile(vipsHeaderPath)) {
// Ensure 64-bit
if (process.arch !== 'x64') {
error('ARM and 32-bit systems require manual installation - please see http://sharp.dimens.io/en/stable/install/');
// Ensure Intel 64-bit or ARM
if (process.arch === 'ia32') {
error('Intel Architecture 32-bit systems require manual installation - please see http://sharp.dimens.io/en/stable/install/');
}
// Ensure libc >= 2.15
var lddVersion = process.env.LDD_VERSION;
@@ -66,18 +69,31 @@ module.exports.download_vips = function() {
error('libc version ' + libcVersion + ' requires manual installation - please see http://sharp.dimens.io/en/stable/install/');
}
}
// Platform-specific .tar.gz
var tarFilename = ['libvips', process.env.npm_package_config_libvips, process.platform.substr(0, 3)].join('-') + '.tar.gz';
// Arch/platform-specific .tar.gz
var platform = (process.arch === 'arm') ? 'arm' : process.platform.substr(0, 3);
var tarFilename = ['libvips', process.env.npm_package_config_libvips, platform].join('-') + '.tar.gz';
var tarPath = path.join(__dirname, 'packaging', tarFilename);
if (isFile(tarPath)) {
unpack(tarPath);
} else {
// Download
tarPath = path.join(tmp, tarFilename);
// Download to per-process temporary file
tarPath = path.join(tmp, process.pid + '-' + tarFilename);
var tmpFile = fs.createWriteStream(tarPath).on('finish', function() {
unpack(tarPath);
unpack(tarPath, function() {
// Attempt to remove temporary file
try {
fs.unlinkSync(tarPath);
} catch (err) {}
});
});
request(distBaseUrl + tarFilename).on('response', function(response) {
var options = {
url: distBaseUrl + tarFilename
};
if (process.env.npm_config_https_proxy) {
// Use the NPM-configured HTTPS proxy
options.proxy = process.env.npm_config_https_proxy;
}
request(options).on('response', function(response) {
if (response.statusCode !== 200) {
error(distBaseUrl + tarFilename + ' status code ' + response.statusCode);
}

View File

@@ -426,8 +426,6 @@ Use WebP format for the output image.
#### raw()
_Requires libvips 7.42.0+_
Provide raw, uncompressed uint8 (unsigned char) image data for Buffer and Stream based output.
The number of channels depends on the input image and selected options.
@@ -497,13 +495,11 @@ An advanced setting for the _zlib_ compression level of the lossless PNG output
#### withoutAdaptiveFiltering()
_Requires libvips 7.42.0+_
An advanced setting to disable adaptive row filtering for the lossless PNG output format.
#### trellisQuantisation() / trellisQuantization()
_Requires libvips 8.0.0+ compiled against mozjpeg 3.0+_
_Requires libvips to have been compiled with mozjpeg support_
An advanced setting to apply the use of
[trellis quantisation](http://en.wikipedia.org/wiki/Trellis_quantization) with JPEG output.
@@ -511,7 +507,7 @@ Reduces file size and slightly increases relative quality at the cost of increas
#### overshootDeringing()
_Requires libvips 8.0.0+ compiled against mozjpeg 3.0+_
_Requires libvips to have been compiled with mozjpeg support_
An advanced setting to reduce the effects of
[ringing](http://en.wikipedia.org/wiki/Ringing_%28signal%29) in JPEG output,
@@ -519,7 +515,7 @@ in particular where black text appears on a white background (or vice versa).
#### optimiseScans() / optimizeScans()
_Requires libvips 8.0.0+ compiled against mozjpeg 3.0+_
_Requires libvips to have been compiled with mozjpeg support_
An advanced setting for progressive (interlace) JPEG output.
Calculates which spectrum of DCT coefficients uses the fewest bits.
@@ -633,3 +629,31 @@ Provides access to internal task counters.
```javascript
var counters = sharp.counters(); // { queue: 2, process: 4 }
```
#### sharp.simd([enable])
_Requires libvips to have been compiled with liborc support_
Improves the performance of `resize`, `blur` and `sharpen` operations
by taking advantage of the SIMD vector unit of the CPU, e.g. Intel SSE and ARM NEON.
* `enable`, if present, is a boolean where `true` enables and `false` disables the use of SIMD.
This method always returns the current state.
This feature is currently disabled by default
but future versions may enable it by default.
When enabled, versions of liborc prior to 0.4.24
and versions of libvips prior to 8.2.0
have been known to crash under heavy load.
```javascript
var simd = sharp.simd();
// simd is `true` if SIMD is currently enabled
```
```javascript
var simd = sharp.simd(true);
// attempts to enable the use of SIMD, returning true if available
```

View File

@@ -2,7 +2,38 @@
### v0.12 - "*look*"
#### v0.12.0 - TBD
#### v0.12.2 - 16<sup>th</sup> January 2016
* Upgrade libvips to v8.2.0 for improved vips_shrink.
* Add pre-compiled libvips for ARMv6+ CPUs.
* Ensure 16-bit input images work with embed option.
[#325](https://github.com/lovell/sharp/issues/325)
[@janaz](https://github.com/janaz)
* Allow compilation with gmake to provide FreeBSD support.
[#326](https://github.com/lovell/sharp/issues/326)
[@c0decafe](https://github.com/c0decafe)
* Attempt to remove temporary file after installation.
[#331](https://github.com/lovell/sharp/issues/331)
[@dtoubelis](https://github.com/dtoubelis)
#### v0.12.1 - 12<sup>th</sup> December 2015
* Allow use of SIMD vector instructions (via liborc) to be toggled on/off.
[#172](https://github.com/lovell/sharp/issues/172)
[@bkw](https://github.com/bkw)
[@puzrin](https://github.com/puzrin)
* Ensure embedded ICC profiles output with perceptual intent.
[#321](https://github.com/lovell/sharp/issues/321)
[@vlapo](https://github.com/vlapo)
* Use the NPM-configured HTTPS proxy, if any, for binary downloads.
#### v0.12.0 - 23<sup>rd</sup> November 2015
* Bundle pre-compiled libvips and its dependencies for 64-bit Linux and Windows.
[#42](https://github.com/lovell/sharp/issues/42)

View File

@@ -17,20 +17,21 @@ npm install sharp
libvips and its dependencies are fetched and stored within `node_modules/sharp` during `npm install`.
This involves an automated HTTPS download of approximately 6MB.
Most recent 64-bit Linux-based operating systems should "just work", e.g.:
Most recent Linux-based operating systems running on x64 and ARMv6+ CPUs should "just work", e.g.:
* Debian 7, 8
* Ubuntu 12.04, 14.04, 14.10, 15.04, 15.10
* Centos 7
* Fedora 20, 21
* Fedora 21, 22, 23
* openSUSE 13.2
* Archlinux 2015.06.01
* Raspbian Jessie
Preference will be given to an existing globally-installed (via `pkg-config`)
version of libvips that meets the minimum version requirement.
This allows the use of newer versions of libvips with older versions of sharp.
For older and 32-bit Linux-based operating systems,
For older Linux-based operating systems and 32-bit Intel CPUs,
a system-wide installation of the most suitable version of
libvips and its dependencies can be achieved by running
the following command as a user with `sudo` access
@@ -77,6 +78,15 @@ This involves an automated HTTPS download of approximately 9MB.
Only 64-bit (x64) `node.exe` is supported.
The WebP format is currently unavailable on Windows.
### FreeBSD
libvips must be installed before `npm install` is run.
This can be achieved via [FreshPorts](https://www.freshports.org/graphics/vips/):
```sh
cd /usr/ports/graphics/vips/ && make install clean
```
### Heroku
[Alessandro Tagliapietra](https://github.com/alex88) maintains an

View File

@@ -863,3 +863,15 @@ module.exports.concurrency = function(concurrency) {
module.exports.counters = function() {
return sharp.counters();
};
/*
Get and set use of SIMD vector unit instructions
*/
module.exports.simd = function(simd) {
if (typeof simd !== 'boolean') {
simd = null;
}
return sharp.simd(simd);
};
// Switch off default
module.exports.simd(false);

View File

@@ -1,6 +1,6 @@
{
"name": "sharp",
"version": "0.12.0",
"version": "0.12.2",
"author": "Lovell Fuller <npm@lovell.info>",
"contributors": [
"Pierre Inglebert <pierre.inglebert@gmail.com>",
@@ -47,28 +47,28 @@
"vips"
],
"dependencies": {
"bluebird": "^3.0.5",
"color": "^0.10.1",
"nan": "^2.1.0",
"bluebird": "^3.1.1",
"color": "^0.11.1",
"nan": "^2.2.0",
"semver": "^5.1.0",
"request": "^2.67.0",
"tar": "^2.2.1"
},
"devDependencies": {
"async": "^1.5.0",
"coveralls": "^2.11.4",
"async": "^1.5.2",
"coveralls": "^2.11.6",
"exif-reader": "^1.0.0",
"icc": "^0.0.2",
"istanbul": "^0.4.0",
"istanbul": "^0.4.2",
"mocha": "^2.3.4",
"mocha-jshint": "^2.2.5",
"mocha-jshint": "^2.2.6",
"node-cpplint": "^0.4.0",
"rimraf": "^2.4.4",
"rimraf": "^2.5.0",
"bufferutil": "^1.2.1"
},
"license": "Apache-2.0",
"config": {
"libvips": "8.1.1"
"libvips": "8.2.0"
},
"engines": {
"node": ">=0.10"

34
packaging/arm-build.sh Executable file
View File

@@ -0,0 +1,34 @@
#!/bin/sh
if [ $# -lt 1 ]; then
echo "Usage: $0 IP"
echo "Build libvips for ARM using Docker, where IP is"
echo "the address of a Raspberry Pi running HypriotOS"
exit 1
fi
IP="$1"
echo "Verifying connectivity to $IP"
if ! ping -c 1 $IP; then
echo "Could not connect to $IP"
exit 1
fi
if ! type sshpass >/dev/null; then
echo "Please install sshpass"
exit 1
fi
export SSHPASS=hypriot
echo "Copying arm/Dockerfile and arm/build.sh to device"
sshpass -e scp -o PreferredAuthentications=password -r arm root@${IP}:/root
echo "Building Raspbian-based container"
sshpass -e ssh -o PreferredAuthentications=password -t root@${IP} "docker build -t vips-dev-arm arm"
echo "Running arm/build.sh within container"
sshpass -e ssh -o PreferredAuthentications=password -t root@${IP} "docker run -i -t --rm -v \${PWD}/arm:/arm vips-dev-arm sh -c 'cd /arm && ./build.sh' | tee arm/build.log"
echo "Copying resultant tar.gz file from device"
sshpass -e scp -o PreferredAuthentications=password root@${IP}:/root/arm/*.tar.gz .

28
packaging/arm-test.sh Executable file
View File

@@ -0,0 +1,28 @@
#!/bin/sh
if [ $# -lt 1 ]; then
echo "Usage: $0 IP"
echo "Test sharp on ARM using Docker, where IP is"
echo "the address of a Raspberry Pi running HypriotOS"
exit 1
fi
IP="$1"
echo "Verifying connectivity to $IP"
if ! ping -c 1 $IP; then
echo "Could not connect to $IP"
exit 1
fi
if ! type sshpass >/dev/null; then
echo "Please install sshpass"
exit 1
fi
export SSHPASS=hypriot
echo "Copying sharp source to device"
sshpass -e scp -o PreferredAuthentications=password -r ../../sharp root@${IP}:/root/sharp
echo "Compile and test within container"
sshpass -e ssh -o PreferredAuthentications=password -t root@${IP} "docker run -i -t --rm -v \${PWD}/sharp:/s hypriot/rpi-node:5 sh -c 'cd /s && npm install --unsafe-perm && npm test'"

5
packaging/arm/Dockerfile Normal file
View File

@@ -0,0 +1,5 @@
FROM resin/rpi-raspbian:jessie
MAINTAINER Lovell Fuller <npm@lovell.info>
# Build dependencies
RUN apt-get update && apt-get install -y build-essential autoconf libtool nasm gtk-doc-tools texinfo curl

135
packaging/arm/build.sh Executable file
View File

@@ -0,0 +1,135 @@
#!/bin/sh
# To be run inside a Raspbian container
# Working directories
DEPS=/deps
TARGET=/target
mkdir ${DEPS}
mkdir ${TARGET}
# Common build paths and flags
export PKG_CONFIG_PATH="${PKG_CONFIG_PATH}:${TARGET}/lib/pkgconfig"
export PATH="${PATH}:${TARGET}/bin"
export CPPFLAGS="-I${TARGET}/include"
export LDFLAGS="-L${TARGET}/lib"
# Dependency version numbers
VERSION_ZLIB=1.2.8
VERSION_FFI=3.2.1
VERSION_GLIB=2.46.2
VERSION_XML2=2.9.3
VERSION_GSF=1.14.34
VERSION_EXIF=0.6.21
VERSION_JPEG=1.4.2
VERSION_PNG16=1.6.20
VERSION_LCMS2=2.7
VERSION_WEBP=0.5.0
VERSION_TIFF=4.0.6
VERSION_MAGICK=6.9.2-10
VERSION_ORC=0.4.24
VERSION_VIPS=8.2.0
mkdir ${DEPS}/zlib
curl -Ls http://zlib.net/zlib-${VERSION_ZLIB}.tar.xz | tar xJC ${DEPS}/zlib --strip-components=1
cd ${DEPS}/zlib
./configure --prefix=${TARGET} && make install
rm ${TARGET}/lib/libz.a
mkdir ${DEPS}/ffi
curl -Ls ftp://sourceware.org/pub/libffi/libffi-${VERSION_FFI}.tar.gz | tar xzC ${DEPS}/ffi --strip-components=1
cd ${DEPS}/ffi
./configure --prefix=${TARGET} --enable-shared --disable-static --disable-dependency-tracking --disable-builddir && make install-strip
mkdir ${DEPS}/glib
curl -Ls http://ftp.gnome.org/pub/gnome/sources/glib/2.46/glib-${VERSION_GLIB}.tar.xz | tar xJC ${DEPS}/glib --strip-components=1
cd ${DEPS}/glib
./configure --prefix=${TARGET} --enable-shared --disable-static --disable-dependency-tracking && make install-strip
mkdir ${DEPS}/xml2
curl -Ls http://xmlsoft.org/sources/libxml2-${VERSION_XML2}.tar.gz | tar xzC ${DEPS}/xml2 --strip-components=1
cd ${DEPS}/xml2
./configure --prefix=${TARGET} --enable-shared --disable-static --disable-dependency-tracking --without-python --with-zlib=${TARGET} && make install-strip
mkdir ${DEPS}/gsf
curl -Ls http://ftp.gnome.org/pub/GNOME/sources/libgsf/1.14/libgsf-${VERSION_GSF}.tar.xz | tar xJC ${DEPS}/gsf --strip-components=1
cd ${DEPS}/gsf
./configure --prefix=${TARGET} --enable-shared --disable-static --disable-dependency-tracking && make install-strip
mkdir ${DEPS}/exif
curl -Ls http://heanet.dl.sourceforge.net/project/libexif/libexif/${VERSION_EXIF}/libexif-${VERSION_EXIF}.tar.bz2 | tar xjC ${DEPS}/exif --strip-components=1
cd ${DEPS}/exif
./configure --prefix=${TARGET} --enable-shared --disable-static --disable-dependency-tracking && make install-strip
mkdir ${DEPS}/jpeg
curl -Ls http://heanet.dl.sourceforge.net/project/libjpeg-turbo/${VERSION_JPEG}/libjpeg-turbo-${VERSION_JPEG}.tar.gz | tar xzC ${DEPS}/jpeg --strip-components=1
cd ${DEPS}/jpeg
./configure --prefix=${TARGET} --enable-shared --disable-static --disable-dependency-tracking --with-jpeg8 --without-turbojpeg && make install-strip
mkdir ${DEPS}/png16
curl -Ls http://heanet.dl.sourceforge.net/project/libpng/libpng16/${VERSION_PNG16}/libpng-${VERSION_PNG16}.tar.xz | tar xJC ${DEPS}/png16 --strip-components=1
cd ${DEPS}/png16
./configure --prefix=${TARGET} --enable-shared --disable-static --disable-dependency-tracking && make install-strip
mkdir ${DEPS}/lcms2
curl -Ls http://heanet.dl.sourceforge.net/project/lcms/lcms/${VERSION_LCMS2}/lcms2-${VERSION_LCMS2}.tar.gz | tar xzC ${DEPS}/lcms2 --strip-components=1
cd ${DEPS}/lcms2
./configure --prefix=${TARGET} --enable-shared --disable-static --disable-dependency-tracking && make install-strip
mkdir ${DEPS}/webp
curl -Ls http://downloads.webmproject.org/releases/webp/libwebp-${VERSION_WEBP}.tar.gz | tar xzC ${DEPS}/webp --strip-components=1
cd ${DEPS}/webp
./configure --prefix=${TARGET} --enable-shared --disable-static --disable-dependency-tracking && make install-strip
mkdir ${DEPS}/tiff
curl -Ls http://download.osgeo.org/libtiff/tiff-${VERSION_TIFF}.tar.gz /deps/tiff.tar.gz | tar xzC ${DEPS}/tiff --strip-components=1
cd ${DEPS}/tiff
./configure --prefix=${TARGET} --enable-shared --disable-static --disable-dependency-tracking && make install-strip
rm ${TARGET}/lib/libtiffxx*
mkdir ${DEPS}/magick
curl -Ls http://www.imagemagick.org/download/releases/ImageMagick-${VERSION_MAGICK}.tar.xz | tar xJC ${DEPS}/magick --strip-components=1
cd ${DEPS}/magick
./configure --prefix=${TARGET} --enable-shared --disable-static --disable-dependency-tracking --without-magick-plus-plus && make install-strip
mkdir ${DEPS}/orc
curl -Ls http://gstreamer.freedesktop.org/data/src/orc/orc-${VERSION_ORC}.tar.xz | tar xJC ${DEPS}/orc --strip-components=1
cd ${DEPS}/orc
./configure --prefix=${TARGET} --enable-shared --disable-static --disable-dependency-tracking && make install-strip
mkdir ${DEPS}/vips
curl -Ls http://www.vips.ecs.soton.ac.uk/supported/8.2/vips-${VERSION_VIPS}.tar.gz | tar xzC ${DEPS}/vips --strip-components=1
cd ${DEPS}/vips
./configure --prefix=${TARGET} --enable-shared --disable-static --disable-dependency-tracking \
--disable-debug --disable-introspection --without-python --without-fftw \
--with-zip-includes=${TARGET}/include --with-zip-libraries=${TARGET}/lib \
--with-jpeg-includes=${TARGET}/include --with-jpeg-libraries=${TARGET}/lib \
&& make install-strip
# Remove the C++ bindings
cd ${TARGET}/include
rm -rf vips/vipsc++.h vips/vipscpp.h vips/V*.h
cd ${TARGET}/lib
rm -rf pkgconfig .libs *.la libvipsCC* libvips-cpp.*
# Create JSON file of version numbers
cd ${TARGET}
echo "{\n\
\"zlib\": \"${VERSION_ZLIB}\",\n\
\"ffi\": \"${VERSION_FFI}\",\n\
\"glib\": \"${VERSION_GLIB}\",\n\
\"xml\": \"${VERSION_XML2}\",\n\
\"gsf\": \"${VERSION_GSF}\",\n\
\"exif\": \"${VERSION_EXIF}\",\n\
\"jpeg\": \"${VERSION_JPEG}\",\n\
\"png\": \"${VERSION_PNG16}\",\n\
\"lcms\": \"${VERSION_LCMS2}\",\n\
\"webp\": \"${VERSION_WEBP}\",\n\
\"tiff\": \"${VERSION_TIFF}\",\n\
\"magick\": \"${VERSION_MAGICK}\",\n\
\"orc\": \"${VERSION_ORC}\",\n\
\"vips\": \"${VERSION_VIPS}\"\n\
}" >lib/versions.json
# Create .tar.gz
GZIP=-9 tar czf /arm/libvips-${VERSION_VIPS}-arm.tar.gz include lib

View File

@@ -13,14 +13,14 @@ fi
docker build -t vips-dev-win win
WIN_CONTAINER_ID=$(docker run -d vips-dev-win)
docker cp $WIN_CONTAINER_ID:/libvips-8.1.1-win.tar.gz .
docker cp $WIN_CONTAINER_ID:/libvips-8.2.0-win.tar.gz .
docker rm $WIN_CONTAINER_ID
# Linux
docker build -t vips-dev-lin lin
LIN_CONTAINER_ID=$(docker run -d vips-dev-lin)
docker cp $LIN_CONTAINER_ID:/libvips-8.1.1-lin.tar.gz .
docker cp $LIN_CONTAINER_ID:/libvips-8.2.0-lin.tar.gz .
docker rm $LIN_CONTAINER_ID
# Checksums

View File

@@ -4,32 +4,32 @@ MAINTAINER Lovell Fuller <npm@lovell.info>
# Build dependencies
RUN apt-get update && apt-get install -y build-essential autoconf libtool nasm gtk-doc-tools texinfo
# Working directories
ENV DEPS /deps
ENV TARGET /target
# Create working directories
ENV DEPS=/deps \
TARGET=/target
RUN mkdir ${DEPS} && mkdir ${TARGET}
# Common build paths and flags
ENV PKG_CONFIG_PATH ${PKG_CONFIG_PATH}:${TARGET}/lib/pkgconfig
ENV PATH ${PATH}:${TARGET}/bin
ENV CPPFLAGS -I${TARGET}/include
ENV LDFLAGS -L${TARGET}/lib
ENV PKG_CONFIG_PATH=${PKG_CONFIG_PATH}:${TARGET}/lib/pkgconfig \
PATH=${PATH}:${TARGET}/bin \
CPPFLAGS=-I${TARGET}/include \
LDFLAGS=-L${TARGET}/lib
# Dependency version numbers
ENV VERSION_ZLIB 1.2.8
ENV VERSION_FFI 3.2.1
ENV VERSION_GLIB 2.46.2
ENV VERSION_XML2 2.9.2
ENV VERSION_GSF 1.14.34
ENV VERSION_EXIF 0.6.21
ENV VERSION_JPEG 1.4.2
ENV VERSION_PNG16 1.6.19
ENV VERSION_LCMS2 2.7
ENV VERSION_WEBP 0.4.4
ENV VERSION_TIFF 4.0.6
ENV VERSION_MAGICK 6.9.2-6
ENV VERSION_ORC 0.4.24
ENV VERSION_VIPS 8.1.1
ENV VERSION_ZLIB=1.2.8 \
VERSION_FFI=3.2.1 \
VERSION_GLIB=2.46.2 \
VERSION_XML2=2.9.3 \
VERSION_GSF=1.14.34 \
VERSION_EXIF=0.6.21 \
VERSION_JPEG=1.4.2 \
VERSION_PNG16=1.6.20 \
VERSION_LCMS2=2.7 \
VERSION_WEBP=0.5.0 \
VERSION_TIFF=4.0.6 \
VERSION_MAGICK=6.9.2-10 \
VERSION_ORC=0.4.24 \
VERSION_VIPS=8.2.0
RUN mkdir ${DEPS}/zlib
RUN curl -Ls http://zlib.net/zlib-${VERSION_ZLIB}.tar.xz | tar xJC ${DEPS}/zlib --strip-components=1
@@ -58,22 +58,22 @@ WORKDIR ${DEPS}/gsf
RUN ./configure --prefix=${TARGET} --enable-shared --disable-static --disable-dependency-tracking && make install-strip
RUN mkdir ${DEPS}/exif
RUN curl -Ls http://kent.dl.sourceforge.net/project/libexif/libexif/${VERSION_EXIF}/libexif-${VERSION_EXIF}.tar.bz2 | tar xjC ${DEPS}/exif --strip-components=1
RUN curl -Ls http://heanet.dl.sourceforge.net/project/libexif/libexif/${VERSION_EXIF}/libexif-${VERSION_EXIF}.tar.bz2 | tar xjC ${DEPS}/exif --strip-components=1
WORKDIR ${DEPS}/exif
RUN ./configure --prefix=${TARGET} --enable-shared --disable-static --disable-dependency-tracking && make install-strip
RUN mkdir ${DEPS}/jpeg
RUN curl -Ls http://kent.dl.sourceforge.net/project/libjpeg-turbo/${VERSION_JPEG}/libjpeg-turbo-${VERSION_JPEG}.tar.gz | tar xzC ${DEPS}/jpeg --strip-components=1
RUN curl -Ls http://heanet.dl.sourceforge.net/project/libjpeg-turbo/${VERSION_JPEG}/libjpeg-turbo-${VERSION_JPEG}.tar.gz | tar xzC ${DEPS}/jpeg --strip-components=1
WORKDIR ${DEPS}/jpeg
RUN ./configure --prefix=${TARGET} --enable-shared --disable-static --disable-dependency-tracking --with-jpeg8 --without-turbojpeg && make install-strip
RUN mkdir ${DEPS}/png16
RUN curl -Ls http://kent.dl.sourceforge.net/project/libpng/libpng16/${VERSION_PNG16}/libpng-${VERSION_PNG16}.tar.xz | tar xJC ${DEPS}/png16 --strip-components=1
RUN curl -Ls http://heanet.dl.sourceforge.net/project/libpng/libpng16/${VERSION_PNG16}/libpng-${VERSION_PNG16}.tar.xz | tar xJC ${DEPS}/png16 --strip-components=1
WORKDIR ${DEPS}/png16
RUN ./configure --prefix=${TARGET} --enable-shared --disable-static --disable-dependency-tracking && make install-strip
RUN mkdir ${DEPS}/lcms2
RUN curl -Ls http://kent.dl.sourceforge.net/project/lcms/lcms/${VERSION_LCMS2}/lcms2-${VERSION_LCMS2}.tar.gz | tar xzC ${DEPS}/lcms2 --strip-components=1
RUN curl -Ls http://heanet.dl.sourceforge.net/project/lcms/lcms/${VERSION_LCMS2}/lcms2-${VERSION_LCMS2}.tar.gz | tar xzC ${DEPS}/lcms2 --strip-components=1
WORKDIR ${DEPS}/lcms2
RUN ./configure --prefix=${TARGET} --enable-shared --disable-static --disable-dependency-tracking && make install-strip
@@ -99,7 +99,7 @@ WORKDIR ${DEPS}/orc
RUN ./configure --prefix=${TARGET} --enable-shared --disable-static --disable-dependency-tracking && make install-strip
RUN mkdir ${DEPS}/vips
RUN curl -Ls http://www.vips.ecs.soton.ac.uk/supported/8.1/vips-${VERSION_VIPS}.tar.gz | tar xzC ${DEPS}/vips --strip-components=1
RUN curl -Ls http://www.vips.ecs.soton.ac.uk/supported/8.2/vips-${VERSION_VIPS}.tar.gz | tar xzC ${DEPS}/vips --strip-components=1
WORKDIR ${DEPS}/vips
RUN ./configure --prefix=${TARGET} --enable-shared --disable-static --disable-dependency-tracking \
--disable-debug --disable-introspection --without-python --without-fftw \

View File

@@ -6,11 +6,12 @@ RUN apt-get update && apt-get install -y curl zip
# Fetch and unzip
RUN mkdir /vips
WORKDIR /vips
RUN curl -O http://www.vips.ecs.soton.ac.uk/supported/8.1/win32/vips-dev-w64-8.1.1-3.zip
RUN unzip vips-dev-w64-8.1.1-3.zip
RUN curl -O http://www.vips.ecs.soton.ac.uk/supported/8.2/win32/vips-dev-w64-8.2.zip
RUN unzip vips-dev-w64-8.2.zip
# Clean and zip
WORKDIR /vips/vips-dev-8.1.1
WORKDIR /vips/vips-dev-8.2
RUN rm bin/libvipsCC-42.dll bin/libvips-cpp-42.dll bin/libgsf-win32-1-114.dll bin/libstdc++-6.dll
RUN cp bin/*.dll lib/
RUN GZIP=-9 tar czf /libvips-8.1.1-win.tar.gz include lib/glib-2.0 lib/libvips.lib lib/libglib-2.0.lib lib/libgobject-2.0.lib lib/*.dll
RUN cp -r lib64/* lib/
RUN GZIP=-9 tar czf /libvips-8.2.0-win.tar.gz include lib/glib-2.0 lib/libvips.lib lib/libglib-2.0.lib lib/libgobject-2.0.lib lib/*.dll

View File

@@ -9,12 +9,12 @@
# * Elementary 0.3
# * Red Hat Linux
# * RHEL/Centos/Scientific 6, 7
# * Fedora 21, 22
# * Fedora 21, 22, 23
# * Amazon Linux 2015.03, 2015.09
# * OpenSuse 13
vips_version_minimum=7.40.0
vips_version_latest_major_minor=8.1
vips_version_minimum=8.2.0
vips_version_latest_major_minor=8.2
vips_version_latest_patch=1
openslide_version_minimum=3.4.0
@@ -211,18 +211,8 @@ if [ -f /etc/debian_version ]; then
DISTRO=$(lsb_release -c -s)
echo "Detected Debian Linux '$DISTRO'"
case "$DISTRO" in
jessie|vivid|wily)
# Debian 8, Ubuntu 15
if [ $enable_openslide -eq 1 ]; then
echo "Recompiling vips with openslide support"
install_libvips_from_source
else
echo "Installing libvips via apt-get"
apt-get install -y libvips-dev libgsf-1-dev
fi
;;
trusty|utopic|qiana|rebecca|rafaela|freya)
# Ubuntu 14, Mint 17
jessie|trusty|utopic|vivid|wily|xenial|qiana|rebecca|rafaela|freya)
# Debian 8, Ubuntu 14.04+, Mint 17
echo "Installing libvips dependencies via apt-get"
apt-get install -y automake build-essential gobject-introspection gtk-doc-tools libglib2.0-dev libjpeg-dev libpng12-dev libwebp-dev libtiff5-dev libexif-dev libgsf-1-dev liblcms2-dev libxml2-dev swig libmagickcore-dev curl
install_libvips_from_source
@@ -263,18 +253,12 @@ elif [ -f /etc/redhat-release ]; then
yum install -y --enablerepo=remi libwebp-devel
install_libvips_from_source "--prefix=/usr"
;;
"Fedora release 21 "*|"Fedora release 22 "*)
# Fedora 21, 22
if [ $enable_openslide -eq 1 ]; then
echo "Installing libvips dependencies via yum"
yum groupinstall -y "Development Tools"
yum install -y gcc-c++ gtk-doc libxml2-devel libjpeg-turbo-devel libpng-devel libtiff-devel libexif-devel lcms-devel ImageMagick-devel gobject-introspection-devel libwebp-devel curl
echo "Compiling vips with openslide support"
install_libvips_from_source "--prefix=/usr"
else
echo "Installing libvips via yum"
yum install -y vips-devel
fi
"Fedora"*)
# Fedora 21, 22, 23
echo "Installing libvips dependencies via yum"
yum groupinstall -y "Development Tools"
yum install -y gcc-c++ gtk-doc libxml2-devel libjpeg-turbo-devel libpng-devel libtiff-devel libexif-devel lcms-devel ImageMagick-devel gobject-introspection-devel libwebp-devel curl
install_libvips_from_source "--prefix=/usr"
;;
*)
# Unsupported RHEL-based OS

View File

@@ -421,7 +421,10 @@ class PipelineWorker : public AsyncWorker {
if (HasProfile(image)) {
// Convert to sRGB using embedded profile
VipsImage *transformed;
if (!vips_icc_transform(image, &transformed, srgbProfile.data(), "embedded", TRUE, nullptr)) {
if (
!vips_icc_transform(image, &transformed, srgbProfile.data(),
"embedded", TRUE, "intent", VIPS_INTENT_PERCEPTUAL, nullptr)
) {
// Embedded profile can fail, so only update references on success
vips_object_local(hook, transformed);
image = transformed;
@@ -430,7 +433,10 @@ class PipelineWorker : public AsyncWorker {
// Convert to sRGB using default "USWebCoatedSWOP" CMYK profile
std::string cmykProfile = baton->iccProfilePath + "USWebCoatedSWOP.icc";
VipsImage *transformed;
if (vips_icc_transform(image, &transformed, srgbProfile.data(), "input_profile", cmykProfile.data(), nullptr)) {
if (
vips_icc_transform(image, &transformed, srgbProfile.data(),
"input_profile", cmykProfile.data(), "intent", VIPS_INTENT_PERCEPTUAL, nullptr)
) {
return Error();
}
vips_object_local(hook, transformed);
@@ -621,16 +627,6 @@ class PipelineWorker : public AsyncWorker {
// Crop/embed
if (image->Xsize != baton->width || image->Ysize != baton->height) {
if (baton->canvas == Canvas::EMBED) {
// Match background colour space, namely sRGB
if (image->Type != VIPS_INTERPRETATION_sRGB) {
// Convert to sRGB colour space
VipsImage *colourspaced;
if (vips_colourspace(image, &colourspaced, VIPS_INTERPRETATION_sRGB, nullptr)) {
return Error();
}
vips_object_local(hook, colourspaced);
image = colourspaced;
}
// Add non-transparent alpha channel, if required
if (baton->background[3] < 255.0 && !HasAlpha(image)) {
// Create single-channel transparency
@@ -655,13 +651,22 @@ class PipelineWorker : public AsyncWorker {
}
// Create background
VipsArrayDouble *background;
// Scale up 8-bit values to match 16-bit input image
double multiplier = (image->Type == VIPS_INTERPRETATION_RGB16) ? 256.0 : 1.0;
if (baton->background[3] < 255.0 || HasAlpha(image)) {
background = vips_array_double_newv(
4, baton->background[0], baton->background[1], baton->background[2], baton->background[3]
// RGBA
background = vips_array_double_newv(4,
baton->background[0] * multiplier,
baton->background[1] * multiplier,
baton->background[2] * multiplier,
baton->background[3] * multiplier
);
} else {
background = vips_array_double_newv(
3, baton->background[0], baton->background[1], baton->background[2]
// RGB
background = vips_array_double_newv(3,
baton->background[0] * multiplier,
baton->background[1] * multiplier,
baton->background[2] * multiplier
);
}
// Embed

2
src/sharp.cc Executable file → Normal file
View File

@@ -26,6 +26,8 @@ NAN_MODULE_INIT(init) {
Nan::GetFunction(Nan::New<v8::FunctionTemplate>(concurrency)).ToLocalChecked());
Nan::Set(target, Nan::New("counters").ToLocalChecked(),
Nan::GetFunction(Nan::New<v8::FunctionTemplate>(counters)).ToLocalChecked());
Nan::Set(target, Nan::New("simd").ToLocalChecked(),
Nan::GetFunction(Nan::New<v8::FunctionTemplate>(simd)).ToLocalChecked());
Nan::Set(target, Nan::New("libvipsVersion").ToLocalChecked(),
Nan::GetFunction(Nan::New<v8::FunctionTemplate>(libvipsVersion)).ToLocalChecked());
Nan::Set(target, Nan::New("format").ToLocalChecked(),

View File

@@ -1,6 +1,7 @@
#include <cmath>
#include <node.h>
#include <vips/vips.h>
#include <vips/vector.h>
#include "nan.h"
@@ -81,6 +82,20 @@ NAN_METHOD(counters) {
info.GetReturnValue().Set(counters);
}
/*
Get and set use of SIMD vector unit instructions
*/
NAN_METHOD(simd) {
HandleScope();
// Set state
if (info[0]->IsBoolean()) {
vips_vector_set_enabled(To<bool>(info[0]).FromJust());
}
// Get state
info.GetReturnValue().Set(New<Boolean>(vips_vector_isenabled()));
}
/*
Get libvips version
*/

1
src/utilities.h Executable file → Normal file
View File

@@ -6,6 +6,7 @@
NAN_METHOD(cache);
NAN_METHOD(concurrency);
NAN_METHOD(counters);
NAN_METHOD(simd);
NAN_METHOD(libvipsVersion);
NAN_METHOD(format);
NAN_METHOD(_maxColourDistance);

View File

@@ -13,7 +13,7 @@
"gm": "^1.21.0",
"imagemagick": "^0.1.3",
"imagemagick-native": "elad/node-imagemagick-native",
"jimp": "^0.2.19",
"jimp": "^0.2.20",
"lwip": "^0.0.8",
"semver": "^5.1.0"
},

View File

@@ -12,6 +12,7 @@ var width = 720;
var height = 480;
sharp.concurrency(1);
sharp.simd(true);
var timer = setInterval(function() {
console.dir(sharp.counters());

View File

@@ -35,6 +35,8 @@ var magickFilterBicubic = 'Lanczos';
// Disable libvips cache to ensure tests are as fair as they can be
sharp.cache(0);
// Enable use of SIMD
sharp.simd(true);
async.series({
'jpeg-linear': function(callback) {
@@ -496,6 +498,24 @@ async.series({
}
});
}
}).add('sharp-without-simd', {
defer: true,
fn: function(deferred) {
sharp.simd(false);
sharp(inputJpgBuffer)
.rotate(90)
.interpolateWith(sharp.interpolator.bilinear)
.resize(width, height)
.toBuffer(function(err, buffer) {
sharp.simd(true);
if (err) {
throw err;
} else {
assert.notStrictEqual(null, buffer);
deferred.resolve();
}
});
}
}).add('sharp-sequentialRead', {
defer: true,
fn: function(deferred) {

View File

@@ -8,6 +8,8 @@ var Benchmark = require('benchmark');
var sharp = require('../../index');
var fixtures = require('../fixtures');
sharp.simd(true);
var min = 320;
var max = 960;

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

BIN
test/fixtures/expected/embed-16bit.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 827 B

View File

@@ -61,12 +61,12 @@ describe('Colour space conversion', function() {
.resize(320, 240)
.background('white')
.embed()
.toFile(fixtures.path('output.cmyk2srgb.jpg'), function(err, info) {
.toBuffer(function(err, data, info) {
if (err) throw err;
assert.strictEqual('jpeg', info.format);
assert.strictEqual(320, info.width);
assert.strictEqual(240, info.height);
done();
fixtures.assertSimilar(fixtures.expected('colourspace.cmyk.jpg'), data, done);
});
});
@@ -75,10 +75,9 @@ describe('Colour space conversion', function() {
.resize(320)
.toBuffer(function(err, data, info) {
if (err) throw err;
assert.strictEqual(true, data.length > 0);
assert.strictEqual('jpeg', info.format);
assert.strictEqual(320, info.width);
done();
fixtures.assertSimilar(fixtures.expected('colourspace.cmyk-without-profile.jpg'), data, done);
});
});

View File

@@ -68,6 +68,20 @@ describe('Embed', function() {
});
});
it('16-bit PNG with alpha channel', function(done) {
sharp(fixtures.inputPngWithTransparency16bit)
.resize(32, 16)
.embed()
.toBuffer(function(err, data, info) {
if (err) throw err;
assert.strictEqual(true, data.length > 0);
assert.strictEqual('png', info.format);
assert.strictEqual(32, info.width);
assert.strictEqual(16, info.height);
fixtures.assertSimilar(fixtures.expected('embed-16bit.png'), data, done);
});
});
it('Enlarge and embed', function(done) {
sharp(fixtures.inputPngWithOneColor)
.embed()

View File

@@ -51,6 +51,21 @@ describe('Utilities', function() {
});
});
describe('SIMD', function() {
it('Can get current state', function() {
var simd = sharp.simd();
assert.strictEqual(typeof simd, 'boolean');
});
it('Can disable', function() {
var simd = sharp.simd(false);
assert.strictEqual(simd, false);
});
it('Can attempt to enable', function() {
var simd = sharp.simd(true);
assert.strictEqual(typeof simd, 'boolean');
});
});
describe('Format', function() {
it('Contains expected attributes', function() {
assert.strictEqual('object', typeof sharp.format);