From 57946ed672d37a3fcf19c6ac61a7d3dad22b597c Mon Sep 17 00:00:00 2001 From: Lovell Fuller Date: Thu, 27 Jul 2017 14:12:40 +0100 Subject: [PATCH] Upgrade to libvips v8.6.0 Expose offset coordinates of strategy-based crop Switch to Github releases for prebuilt libvips Move packaging scripts to lovell/sharp-libvips repo --- .gitattributes | 1 + .gitignore | 4 +- CONTRIBUTING.md | 4 +- appveyor.yml | 2 +- binding.gyp | 8 +- binding.js | 59 ++-- circle.yml | 8 - docs/changelog.md | 10 + lib/output.js | 1 + package.json | 15 +- packaging/README.md | 57 ---- packaging/build.sh | 48 ---- packaging/build/lin.sh | 256 ------------------ packaging/build/win.sh | 19 -- packaging/linux-armv6/Dockerfile | 15 - packaging/linux-armv7/Dockerfile | 20 -- packaging/linux-armv8/Dockerfile | 18 -- packaging/linux-x64/Dockerfile | 16 -- packaging/test-linux-arm.sh | 28 -- packaging/test-linux-x64.sh | 36 --- packaging/test/archlinux.sh | 5 - packaging/test/centos.sh | 4 - packaging/test/debian.sh | 6 - packaging/win32-x64/Dockerfile | 8 - src/libvips/cplusplus/VImage.cpp | 34 +-- src/pipeline.cc | 11 +- src/pipeline.h | 10 +- .../expected/crop-strategy-attention.jpg | Bin 4514 -> 5924 bytes test/unit/crop.js | 12 + test/unit/io.js | 2 +- 30 files changed, 86 insertions(+), 631 deletions(-) create mode 100644 .gitattributes delete mode 100644 circle.yml delete mode 100644 packaging/README.md delete mode 100755 packaging/build.sh delete mode 100755 packaging/build/lin.sh delete mode 100755 packaging/build/win.sh delete mode 100644 packaging/linux-armv6/Dockerfile delete mode 100644 packaging/linux-armv7/Dockerfile delete mode 100644 packaging/linux-armv8/Dockerfile delete mode 100644 packaging/linux-x64/Dockerfile delete mode 100755 packaging/test-linux-arm.sh delete mode 100755 packaging/test-linux-x64.sh delete mode 100755 packaging/test/archlinux.sh delete mode 100755 packaging/test/centos.sh delete mode 100755 packaging/test/debian.sh delete mode 100644 packaging/win32-x64/Dockerfile diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..57bc2fef --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +src/libvips/* linguist-vendored diff --git a/.gitignore b/.gitignore index 94a990fb..c043cd1c 100644 --- a/.gitignore +++ b/.gitignore @@ -9,8 +9,6 @@ test/saliency/Image* test/saliency/[Uu]serData* !test/saliency/userData.js vendor -packaging/libvips* -packaging/*.log -!packaging/build +.gitattributes .DS_Store .nyc_output diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 89fbdc1c..03202221 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -14,7 +14,7 @@ New bugs are assigned a `triage` label whilst under investigation. If a [similar request](https://github.com/lovell/sharp/labels/enhancement) exists, it's probably fastest to add a comment to it about your requirement. -Implementation is usually straightforward if _libvips_ [already supports](http://www.vips.ecs.soton.ac.uk/supported/current/doc/html/libvips/ch03.html) the feature you need. +Implementation is usually straightforward if _libvips_ [already supports](https://jcupitt.github.io/libvips/API/current/) the feature you need. ## Submit a Pull Request to fix a bug @@ -41,8 +41,8 @@ Any change that modifies the existing public API should be added to the relevant | Release | WIP branch | | ------: | :--------- | -| v0.18.0 | ridge | | v0.19.0 | suit | +| v0.20.0 | teeth | Please squash your changes into a single commit using a command like `git rebase -i upstream/`. diff --git a/appveyor.yml b/appveyor.yml index c77dfaec..a0238852 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -6,7 +6,7 @@ environment: matrix: - nodejs_version: "4" - nodejs_version: "6" - - nodejs_version: "7" + - nodejs_version: "8" install: - ps: Install-Product node $env:nodejs_version x64 - npm install -g npm@latest diff --git a/binding.gyp b/binding.gyp index f20036a2..3476d888 100644 --- a/binding.gyp +++ b/binding.gyp @@ -230,7 +230,6 @@ 'copies': [{ 'destination': 'build/Release', 'files': [ - 'vendor/lib/GNU.Gettext.dll', 'vendor/lib/libasprintf-0.dll', 'vendor/lib/libcairo-2.dll', 'vendor/lib/libcairo-gobject-2.dll', @@ -245,6 +244,9 @@ 'vendor/lib/libfreetype-6.dll', 'vendor/lib/libgcc_s_seh-1.dll', 'vendor/lib/libgdk_pixbuf-2.0-0.dll', + 'vendor/lib/libgettextlib-0-19-8.dll', + 'vendor/lib/libgettextpo-1.dll', + 'vendor/lib/libgettextsrc-0-19-8.dll', 'vendor/lib/libgif-7.dll', 'vendor/lib/libgio-2.0-0.dll', 'vendor/lib/libglib-2.0-0.dll', @@ -252,12 +254,14 @@ 'vendor/lib/libgobject-2.0-0.dll', 'vendor/lib/libgsf-1-114.dll', 'vendor/lib/libgthread-2.0-0.dll', + 'vendor/lib/libharfbuzz-0.dll', 'vendor/lib/libiconv-2.dll', - 'vendor/lib/libintl-8.dll', + 'vendor/lib/libintl-9.dll', 'vendor/lib/libjpeg-62.dll', 'vendor/lib/liblcms2-2.dll', 'vendor/lib/libpango-1.0-0.dll', 'vendor/lib/libpangocairo-1.0-0.dll', + 'vendor/lib/libpangoft2-1.0-0.dll', 'vendor/lib/libpangowin32-1.0-0.dll', 'vendor/lib/libpixman-1-0.dll', 'vendor/lib/libpng16-16.dll', diff --git a/binding.js b/binding.js index 4f2aa7a6..0ef7e57b 100644 --- a/binding.js +++ b/binding.js @@ -10,11 +10,11 @@ const semver = require('semver'); const tar = require('tar'); const detectLibc = require('detect-libc'); -const distBaseUrl = process.env.SHARP_DIST_BASE_URL || 'https://dl.bintray.com/lovell/sharp/'; - // Use NPM-provided environment variable where available, falling back to require-based method for Electron const minimumLibvipsVersion = process.env.npm_package_config_libvips || require('./package.json').config.libvips; +const distBaseUrl = process.env.SHARP_DIST_BASE_URL || `https://github.com/lovell/sharp-libvips/releases/download/v${minimumLibvipsVersion}/`; + const platform = process.env.npm_config_platform || process.platform; const arch = process.env.npm_config_arch || process.arch; @@ -81,37 +81,32 @@ module.exports.download_vips = function () { } // Arch/platform-specific .tar.gz const tarFilename = ['libvips', minimumLibvipsVersion, platformId()].join('-') + '.tar.gz'; - const tarPathLocal = path.join(__dirname, 'packaging', tarFilename); - if (isFile(tarPathLocal)) { - unpack(tarPathLocal); - } else { - // Download to per-process temporary file - const tarPathTemp = path.join(os.tmpdir(), process.pid + '-' + tarFilename); - const tmpFile = fs.createWriteStream(tarPathTemp).on('finish', function () { - unpack(tarPathTemp, function () { - // Attempt to remove temporary file - try { - fs.unlinkSync(tarPathTemp); - } catch (err) {} - }); + // Download to per-process temporary file + const tarPathTemp = path.join(os.tmpdir(), process.pid + '-' + tarFilename); + const tmpFile = fs.createWriteStream(tarPathTemp).on('finish', function () { + unpack(tarPathTemp, function () { + // Attempt to remove temporary file + try { + fs.unlinkSync(tarPathTemp); + } catch (err) {} }); - const url = distBaseUrl + tarFilename; - const simpleGetOpt = { - url: url, - agent: caw(null, { - protocol: 'https' - }) - }; - simpleGet(simpleGetOpt, function (err, response) { - if (err) { - error('Download of ' + url + ' failed: ' + err.message); - } - if (response.statusCode !== 200) { - error(url + ' status code ' + response.statusCode); - } - response.pipe(tmpFile); - }); - } + }); + const url = distBaseUrl + tarFilename; + const simpleGetOpt = { + url: url, + agent: caw(null, { + protocol: 'https' + }) + }; + simpleGet(simpleGetOpt, function (err, response) { + if (err) { + error('Download of ' + url + ' failed: ' + err.message); + } + if (response.statusCode !== 200) { + error(url + ' status code ' + response.statusCode); + } + response.pipe(tmpFile); + }); } }; diff --git a/circle.yml b/circle.yml deleted file mode 100644 index 5f7a6210..00000000 --- a/circle.yml +++ /dev/null @@ -1,8 +0,0 @@ -machine: - node: - version: v4.8.4 - services: - - docker -test: - override: - - ./packaging/test-linux-x64.sh diff --git a/docs/changelog.md b/docs/changelog.md index 802a6431..950861da 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -1,5 +1,15 @@ # Changelog +### v0.19 - "*suit*" + +Requires libvips v8.6.0. + +#### v0.19.0 - TBD + +* Expose offset coordinates of strategy-based crop. + [#868](https://github.com/lovell/sharp/issues/868) + [@mirohristov-com](https://github.com/mirohristov-com) + ### v0.18 - "*ridge*" Requires libvips v8.5.5. diff --git a/lib/output.js b/lib/output.js index 881cf374..bce0c7d4 100644 --- a/lib/output.js +++ b/lib/output.js @@ -16,6 +16,7 @@ const sharp = require('../build/Release/sharp.node'); * @param {Function} [callback] - called on completion with two arguments `(err, info)`. * `info` contains the output image `format`, `size` (bytes), `width`, `height`, * `channels` and `premultiplied` (indicating if premultiplication was used). + * When using a crop strategy also contains `cropOffsetLeft` and `cropOffsetTop`. * @returns {Promise} - when no callback is provided * @throws {Error} Invalid parameters */ diff --git a/package.json b/package.json index 7a9cb7f7..d9052ba9 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "sharp", "description": "High performance Node.js image processing, the fastest module to resize JPEG, PNG, WebP and TIFF images", - "version": "0.18.4", + "version": "0.19.0-alpha", "author": "Lovell Fuller ", "homepage": "https://github.com/lovell/sharp", "contributors": [ @@ -44,7 +44,6 @@ "clean": "rm -rf node_modules/ build/ vendor/ coverage/ test/fixtures/output.*", "test": "semistandard && cc && nyc --reporter=lcov --branches=99 mocha --slow=5000 --timeout=60000 ./test/unit/*.js", "test-leak": "./test/leak/leak.sh", - "test-packaging": "./packaging/test-linux-x64.sh", "docs": "for m in constructor input resize composite operation colour channel output utility; do documentation build --shallow --format=md lib/$m.js >docs/api-$m.md; done" }, "main": "lib/index.js", @@ -71,10 +70,10 @@ "caw": "^2.0.0", "color": "^2.0.0", "detect-libc": "^0.2.0", - "nan": "^2.6.2", - "semver": "^5.3.0", + "nan": "^2.7.0", + "semver": "^5.4.1", "simple-get": "^2.7.0", - "tar": "^3.1.5" + "tar": "^4.0.1" }, "devDependencies": { "async": "^2.5.0", @@ -82,15 +81,15 @@ "documentation": "^4.0.0-rc.1", "exif-reader": "^1.0.2", "icc": "^1.0.0", - "mocha": "^3.4.2", - "nyc": "^11.0.3", + "mocha": "^3.5.0", + "nyc": "^11.1.0", "rimraf": "^2.6.1", "semistandard": "^11.0.0", "unzip": "^0.1.11" }, "license": "Apache-2.0", "config": { - "libvips": "8.5.5" + "libvips": "8.6.0" }, "engines": { "node": ">=4.5.0" diff --git a/packaging/README.md b/packaging/README.md deleted file mode 100644 index dbc4e3b6..00000000 --- a/packaging/README.md +++ /dev/null @@ -1,57 +0,0 @@ -# Packaging scripts - -libvips and its dependencies are provided as pre-compiled shared libraries -for the most common operating systems and CPU architectures. - -During `npm install`, these binaries are fetched as tarballs from -[Bintray](https://dl.bintray.com/lovell/sharp/) via HTTPS -and stored locally within `node_modules/sharp`. - -## Using a custom tarball - -A custom tarball stored on the local filesystem can be used instead. -Place it in the following location, where `x.y.z` is the libvips version, -`platform` is the value of `process.platform` and -`arch` is the value of `process.arch` (plus the version number for ARM). - -`node_modules/sharp/packaging/libvips-x.y.z-platform-arch.tar.gz` - -For example, for libvips v8.3.3 on an ARMv6 Linux machine, use: - -`node_modules/sharp/packaging/libvips-8.3.3-linux-armv6.tar.gz` - -Remove any `sharp/lib` and `sharp/include` directories -before running `npm install` again. - -## Creating a tarball - -Most people will not need to do this; proceed with caution. - -The `packaging` directory contains the top-level [build script](build.sh). - -### Linux - -One [build script](build/lin.sh) is used to (cross-)compile -the same shared libraries within multiple containers. - -* [x64](linux-x64/Dockerfile) -* [ARMv6](linux-armv6/Dockerfile) -* [ARMv7-A](linux-armv7/Dockerfile) -* [ARMv8-A](linux-armv8/Dockerfile) - -The QEMU user mode emulation binaries are required to build for -the ARMv6 platform as the Debian armhf cross-compiler erroneously -generates unsupported Thumb 2 instructions. - -```sh -sudo apt-get install qemu-user-static -``` - -### Windows - -The output of libvips' [build-win64](https://github.com/jcupitt/build-win64) -"web" target is [post-processed](build/win.sh) within a [container](win32-x64/Dockerfile). - -### OS X - -See [package-libvips-darwin](https://github.com/lovell/package-libvips-darwin). diff --git a/packaging/build.sh b/packaging/build.sh deleted file mode 100755 index 7c8364cb..00000000 --- a/packaging/build.sh +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/sh -set -e - -if [ $# -lt 1 ]; then - echo - echo "Usage: $0 VERSION [PLATFORM]" - echo "Build shared libraries for libvips and its dependencies via containers" - echo - echo "Please specify the libvips VERSION, e.g. 8.3.3" - echo - echo "Optionally build for only one PLATFORM, defaults to building for all" - echo "Possible values for PLATFORM are: win32-x64, linux-x64, linux-armv6," - echo "linux-armv7, linux-armv8" - echo - exit 1 -fi -VERSION_VIPS="$1" -PLATFORM="${2:-all}" - -# Is docker available? -if ! type docker >/dev/null; then - echo "Please install docker" - exit 1 -fi - -# Update base images -for baseimage in debian:wheezy debian:jessie debian:stretch socialdefect/raspbian-jessie-core; do - docker pull $baseimage -done - -# Windows (x64) -if [ $PLATFORM = "all" ] || [ $PLATFORM = "win32-x64" ]; then - echo "Building win32-x64..." - docker build -t vips-dev-win32-x64 win32-x64 - docker run --rm -e "VERSION_VIPS=${VERSION_VIPS}" -v $PWD:/packaging vips-dev-win32-x64 sh -c "/packaging/build/win.sh" -fi - -# Linux (x64, ARMv6, ARMv7, ARMv8) -for flavour in linux-x64 linux-armv6 linux-armv7 linux-armv8; do - if [ $PLATFORM = "all" ] || [ $PLATFORM = $flavour ]; then - echo "Building $flavour..." - docker build -t vips-dev-$flavour $flavour - docker run --rm -e "VERSION_VIPS=${VERSION_VIPS}" -v $PWD:/packaging vips-dev-$flavour sh -c "/packaging/build/lin.sh" - fi -done - -# Display checksums -sha256sum *.tar.gz diff --git a/packaging/build/lin.sh b/packaging/build/lin.sh deleted file mode 100755 index 2f559f7e..00000000 --- a/packaging/build/lin.sh +++ /dev/null @@ -1,256 +0,0 @@ -#!/bin/sh -set -e - -# 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" -export CFLAGS="${FLAGS}" -export CXXFLAGS="${FLAGS}" - -# Dependency version numbers -VERSION_ZLIB=1.2.11 -VERSION_FFI=3.2.1 -VERSION_GLIB=2.53.1 -VERSION_XML2=2.9.4 -VERSION_GSF=1.14.41 -VERSION_EXIF=0.6.21 -VERSION_LCMS2=2.8 -VERSION_JPEG=1.5.1 -VERSION_PNG16=1.6.29 -VERSION_WEBP=0.6.0 -VERSION_TIFF=4.0.7 -VERSION_ORC=0.4.26 -VERSION_GDKPIXBUF=2.36.6 -VERSION_FREETYPE=2.8 -VERSION_EXPAT=2.2.0 -VERSION_FONTCONFIG=2.12.1 -VERSION_HARFBUZZ=1.4.6 -VERSION_PIXMAN=0.34.0 -VERSION_CAIRO=1.14.8 -VERSION_PANGO=1.40.5 -VERSION_CROCO=0.6.12 -VERSION_SVG=2.40.17 -VERSION_GIF=5.1.4 - -# Least out-of-sync Sourceforge mirror -SOURCEFORGE_MIRROR=netix - -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} --uname=linux -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 --host=${CHOST} --prefix=${TARGET} --enable-shared --disable-static --disable-dependency-tracking --disable-builddir -make install-strip - -mkdir ${DEPS}/glib -curl -Ls https://download.gnome.org/sources/glib/2.53/glib-${VERSION_GLIB}.tar.xz | tar xJC ${DEPS}/glib --strip-components=1 -cd ${DEPS}/glib -echo glib_cv_stack_grows=no >>glib.cache -echo glib_cv_uscore=no >>glib.cache -./configure --cache-file=glib.cache --host=${CHOST} --prefix=${TARGET} --enable-shared --disable-static --disable-dependency-tracking \ - --with-pcre=internal --disable-libmount -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 --host=${CHOST} --prefix=${TARGET} --enable-shared --disable-static --disable-dependency-tracking \ - --without-python --without-debug --without-docbook --without-ftp --without-html --without-legacy \ - --without-pattern --without-push --without-regexps --without-schemas --without-schematron --with-zlib=${TARGET} -make install-strip - -mkdir ${DEPS}/gsf -curl -Ls https://download.gnome.org/sources/libgsf/1.14/libgsf-${VERSION_GSF}.tar.xz | tar xJC ${DEPS}/gsf --strip-components=1 -cd ${DEPS}/gsf -./configure --host=${CHOST} --prefix=${TARGET} --enable-shared --disable-static --disable-dependency-tracking -make install-strip - -mkdir ${DEPS}/exif -curl -Ls http://${SOURCEFORGE_MIRROR}.dl.sourceforge.net/project/libexif/libexif/${VERSION_EXIF}/libexif-${VERSION_EXIF}.tar.bz2 | tar xjC ${DEPS}/exif --strip-components=1 -cd ${DEPS}/exif -autoreconf -fiv -./configure --host=${CHOST} --prefix=${TARGET} --enable-shared --disable-static --disable-dependency-tracking -make install-strip - -mkdir ${DEPS}/lcms2 -curl -Ls http://${SOURCEFORGE_MIRROR}.dl.sourceforge.net/project/lcms/lcms/${VERSION_LCMS2}/lcms2-${VERSION_LCMS2}.tar.gz | tar xzC ${DEPS}/lcms2 --strip-components=1 -cd ${DEPS}/lcms2 -# Apply patches for lcms2 vulnerabilities reported since v2.8 -VERSION_LCMS2_GIT_MASTER_SHA=$(curl -Ls https://api.github.com/repos/mm2/Little-CMS/git/refs/heads/master | jq -r '.object.sha' | head -c7) -curl -Ls https://github.com/mm2/Little-CMS/compare/lcms2.8...master.patch | patch -p1 -t || true -./configure --host=${CHOST} --prefix=${TARGET} --enable-shared --disable-static --disable-dependency-tracking -make install-strip - -mkdir ${DEPS}/jpeg -curl -Ls https://github.com/libjpeg-turbo/libjpeg-turbo/archive/${VERSION_JPEG}.tar.gz | tar xzC ${DEPS}/jpeg --strip-components=1 -cd ${DEPS}/jpeg -autoreconf -fiv -./configure --host=${CHOST} --prefix=${TARGET} --enable-shared --disable-static --disable-dependency-tracking --with-jpeg8 --without-turbojpeg -make install-strip - -mkdir ${DEPS}/png16 -curl -Ls http://${SOURCEFORGE_MIRROR}.dl.sourceforge.net/project/libpng/libpng16/${VERSION_PNG16}/libpng-${VERSION_PNG16}.tar.xz | tar xJC ${DEPS}/png16 --strip-components=1 -cd ${DEPS}/png16 -./configure --host=${CHOST} --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 --host=${CHOST} --prefix=${TARGET} --enable-shared --disable-static --disable-dependency-tracking \ - --disable-neon --enable-libwebpmux -make install-strip - -mkdir ${DEPS}/tiff -curl -Ls http://download.osgeo.org/libtiff/tiff-${VERSION_TIFF}.tar.gz | tar xzC ${DEPS}/tiff --strip-components=1 -cd ${DEPS}/tiff -# Apply patches for libtiff vulnerabilities reported since v4.0.7 -VERSION_TIFF_GIT_MASTER_SHA=$(curl -Ls https://api.github.com/repos/vadz/libtiff/git/refs/heads/master | jq -r '.object.sha' | head -c7) -curl -Ls https://github.com/vadz/libtiff/compare/Release-v4-0-7...master.patch | patch -p1 -t || true -if [ -n "${CHOST}" ]; then autoreconf -fiv; fi -./configure --host=${CHOST} --prefix=${TARGET} --enable-shared --disable-static --disable-dependency-tracking --disable-mdi --disable-pixarlog --disable-cxx -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 --host=${CHOST} --prefix=${TARGET} --enable-shared --disable-static --disable-dependency-tracking -make install-strip -cd ${TARGET}/lib -rm -rf liborc-test-* - -mkdir ${DEPS}/gdkpixbuf -curl -Ls https://download.gnome.org/sources/gdk-pixbuf/2.36/gdk-pixbuf-${VERSION_GDKPIXBUF}.tar.xz | tar xJC ${DEPS}/gdkpixbuf --strip-components=1 -cd ${DEPS}/gdkpixbuf -touch gdk-pixbuf/loaders.cache -LD_LIBRARY_PATH=${TARGET}/lib \ -./configure --host=${CHOST} --prefix=${TARGET} --enable-shared --disable-static --disable-dependency-tracking \ - --disable-introspection --disable-modules --disable-gio-sniffing \ - --without-libtiff --without-gdiplus --with-included-loaders=png,jpeg -make install-strip - -mkdir ${DEPS}/freetype -curl -Ls http://${SOURCEFORGE_MIRROR}.dl.sourceforge.net/project/freetype/freetype2/${VERSION_FREETYPE}/freetype-${VERSION_FREETYPE}.tar.gz | tar xzC ${DEPS}/freetype --strip-components=1 -cd ${DEPS}/freetype -./configure --host=${CHOST} --prefix=${TARGET} --enable-shared --disable-static -make install - -mkdir ${DEPS}/expat -curl -Ls http://${SOURCEFORGE_MIRROR}.dl.sourceforge.net/project/expat/expat/${VERSION_EXPAT}/expat-${VERSION_EXPAT}.tar.bz2 | tar xjC ${DEPS}/expat --strip-components=1 -cd ${DEPS}/expat -./configure --host=${CHOST} --prefix=${TARGET} --enable-shared --disable-static -make install - -mkdir ${DEPS}/fontconfig -curl -Ls https://www.freedesktop.org/software/fontconfig/release/fontconfig-${VERSION_FONTCONFIG}.tar.bz2 | tar xjC ${DEPS}/fontconfig --strip-components=1 -cd ${DEPS}/fontconfig -./configure --host=${CHOST} --prefix=${TARGET} --enable-shared --disable-static --disable-dependency-tracking \ - --with-expat-includes=${TARGET}/include --with-expat-lib=${TARGET}/lib --sysconfdir=/etc -make install-strip - -mkdir ${DEPS}/harfbuzz -curl -Ls https://www.freedesktop.org/software/harfbuzz/release/harfbuzz-${VERSION_HARFBUZZ}.tar.bz2 | tar xjC ${DEPS}/harfbuzz --strip-components=1 -cd ${DEPS}/harfbuzz -./configure --host=${CHOST} --prefix=${TARGET} --enable-shared --disable-static --disable-dependency-tracking -make install-strip - -mkdir ${DEPS}/pixman -curl -Ls http://cairographics.org/releases/pixman-${VERSION_PIXMAN}.tar.gz | tar xzC ${DEPS}/pixman --strip-components=1 -cd ${DEPS}/pixman -./configure --host=${CHOST} --prefix=${TARGET} --enable-shared --disable-static --disable-dependency-tracking --disable-libpng --disable-arm-iwmmxt -make install-strip - -mkdir ${DEPS}/cairo -curl -Ls http://cairographics.org/releases/cairo-${VERSION_CAIRO}.tar.xz | tar xJC ${DEPS}/cairo --strip-components=1 -cd ${DEPS}/cairo -./configure --host=${CHOST} --prefix=${TARGET} --enable-shared --disable-static --disable-dependency-tracking \ - --disable-xlib --disable-xcb --disable-quartz --disable-win32 --disable-egl --disable-glx --disable-wgl \ - --disable-script --disable-ps --disable-gobject --disable-trace --disable-interpreter -make install-strip - -mkdir ${DEPS}/pango -curl -Ls https://download.gnome.org/sources/pango/1.40/pango-${VERSION_PANGO}.tar.xz | tar xJC ${DEPS}/pango --strip-components=1 -cd ${DEPS}/pango -./configure --host=${CHOST} --prefix=${TARGET} --enable-shared --disable-static --disable-dependency-tracking -make install-strip - -mkdir ${DEPS}/croco -curl -Ls https://download.gnome.org/sources/libcroco/0.6/libcroco-${VERSION_CROCO}.tar.xz | tar xJC ${DEPS}/croco --strip-components=1 -cd ${DEPS}/croco -./configure --host=${CHOST} --prefix=${TARGET} --enable-shared --disable-static --disable-dependency-tracking -make install-strip - -mkdir ${DEPS}/svg -curl -Ls https://download.gnome.org/sources/librsvg/2.40/librsvg-${VERSION_SVG}.tar.xz | tar xJC ${DEPS}/svg --strip-components=1 -cd ${DEPS}/svg -./configure --host=${CHOST} --prefix=${TARGET} --enable-shared --disable-static --disable-dependency-tracking --disable-introspection --disable-tools --disable-pixbuf-loader -make install-strip - -mkdir ${DEPS}/gif -curl -Ls http://${SOURCEFORGE_MIRROR}.dl.sourceforge.net/project/giflib/giflib-${VERSION_GIF}.tar.gz | tar xzC ${DEPS}/gif --strip-components=1 -cd ${DEPS}/gif -./configure --host=${CHOST} --prefix=${TARGET} --enable-shared --disable-static --disable-dependency-tracking -make install-strip - -mkdir ${DEPS}/vips -curl -Ls https://github.com/jcupitt/libvips/releases/download/v${VERSION_VIPS}/vips-${VERSION_VIPS}.tar.gz | tar xzC ${DEPS}/vips --strip-components=1 -cd ${DEPS}/vips -./configure --host=${CHOST} --prefix=${TARGET} --enable-shared --disable-static --disable-dependency-tracking \ - --disable-debug --disable-introspection --without-python --without-fftw \ - --without-magick --without-pangoft2 --without-ppm --without-analyze --without-radiance \ - --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 old C++ bindings -cd ${TARGET}/include -rm -rf vips/vipsc++.h vips/vipscpp.h -cd ${TARGET}/lib -rm -rf pkgconfig .libs *.la libvipsCC* - -# Create JSON file of version numbers -cd ${TARGET} -echo "{\n\ - \"cairo\": \"${VERSION_CAIRO}\",\n\ - \"croco\": \"${VERSION_CROCO}\",\n\ - \"exif\": \"${VERSION_EXIF}\",\n\ - \"expat\": \"${VERSION_EXPAT}\",\n\ - \"ffi\": \"${VERSION_FFI}\",\n\ - \"fontconfig\": \"${VERSION_FONTCONFIG}\",\n\ - \"freetype\": \"${VERSION_FREETYPE}\",\n\ - \"gdkpixbuf\": \"${VERSION_GDKPIXBUF}\",\n\ - \"gif\": \"${VERSION_GIF}\",\n\ - \"glib\": \"${VERSION_GLIB}\",\n\ - \"gsf\": \"${VERSION_GSF}\",\n\ - \"harfbuzz\": \"${VERSION_HARFBUZZ}\",\n\ - \"jpeg\": \"${VERSION_JPEG}\",\n\ - \"lcms\": \"${VERSION_LCMS2}-${VERSION_LCMS2_GIT_MASTER_SHA}\",\n\ - \"orc\": \"${VERSION_ORC}\",\n\ - \"pango\": \"${VERSION_PANGO}\",\n\ - \"pixman\": \"${VERSION_PIXMAN}\",\n\ - \"png\": \"${VERSION_PNG16}\",\n\ - \"svg\": \"${VERSION_SVG}\",\n\ - \"tiff\": \"${VERSION_TIFF}-${VERSION_TIFF_GIT_MASTER_SHA}\",\n\ - \"vips\": \"${VERSION_VIPS}\",\n\ - \"webp\": \"${VERSION_WEBP}\",\n\ - \"xml\": \"${VERSION_XML2}\",\n\ - \"zlib\": \"${VERSION_ZLIB}\"\n\ -}" >lib/versions.json - -# Create .tar.gz -tar czf /packaging/libvips-${VERSION_VIPS}-${PLATFORM}.tar.gz include lib -advdef --recompress --shrink-insane /packaging/libvips-${VERSION_VIPS}-${PLATFORM}.tar.gz diff --git a/packaging/build/win.sh b/packaging/build/win.sh deleted file mode 100755 index 31c33e48..00000000 --- a/packaging/build/win.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/sh -set -e - -# Fetch and unzip -mkdir /vips -cd /vips -curl -L -O https://github.com/lovell/build-win64/releases/download/v${VERSION_VIPS}/vips-dev-w64-web-${VERSION_VIPS}.zip -unzip vips-dev-w64-web-${VERSION_VIPS}.zip - -# Clean and zip -cd /vips/vips-dev-8.5 -rm bin/libvipsCC-42.dll bin/libvips-cpp-42.dll bin/libgsf-win32-1-114.dll -cp bin/*.dll lib/ -cp -r lib64/* lib/ - -echo "Creating tarball" -tar czf /packaging/libvips-${VERSION_VIPS}-${PLATFORM}.tar.gz include lib/glib-2.0 lib/libvips.lib lib/libglib-2.0.lib lib/libgobject-2.0.lib lib/*.dll -echo "Shrinking tarball" -advdef --recompress --shrink-insane /packaging/libvips-${VERSION_VIPS}-${PLATFORM}.tar.gz diff --git a/packaging/linux-armv6/Dockerfile b/packaging/linux-armv6/Dockerfile deleted file mode 100644 index af79a935..00000000 --- a/packaging/linux-armv6/Dockerfile +++ /dev/null @@ -1,15 +0,0 @@ -FROM socialdefect/raspbian-jessie-core -MAINTAINER Lovell Fuller - -# Create Rasbian-based container suitable for compiling Linux ARMv6 binaries -# Requires the QEMU user mode emulation binaries on the host machine - -# Build dependencies -RUN \ - apt-get update && \ - apt-get install -y build-essential curl autoconf libtool nasm gtk-doc-tools texinfo advancecomp libglib2.0-dev jq - -# Compiler settings -ENV \ - PLATFORM=linux-armv6 \ - FLAGS="-Os" diff --git a/packaging/linux-armv7/Dockerfile b/packaging/linux-armv7/Dockerfile deleted file mode 100644 index 338c1fd7..00000000 --- a/packaging/linux-armv7/Dockerfile +++ /dev/null @@ -1,20 +0,0 @@ -FROM debian:jessie -MAINTAINER Lovell Fuller - -# Create Debian-based container suitable for cross-compiling Linux ARMv7-A binaries - -# Build dependencies -RUN \ - apt-get update && \ - apt-get install -y curl && \ - echo "deb http://emdebian.org/tools/debian/ jessie main" | tee /etc/apt/sources.list.d/crosstools.list && \ - curl http://emdebian.org/tools/debian/emdebian-toolchain-archive.key | apt-key add - && \ - dpkg --add-architecture armhf && \ - apt-get update && \ - apt-get install -y crossbuild-essential-armhf autoconf libtool nasm gtk-doc-tools texinfo advancecomp libglib2.0-dev jq - -# Compiler settings -ENV \ - PLATFORM=linux-armv7 \ - CHOST=arm-linux-gnueabihf \ - FLAGS="-marm -march=armv7-a -mfpu=neon-vfpv4 -mfloat-abi=hard -Os" diff --git a/packaging/linux-armv8/Dockerfile b/packaging/linux-armv8/Dockerfile deleted file mode 100644 index 12948d96..00000000 --- a/packaging/linux-armv8/Dockerfile +++ /dev/null @@ -1,18 +0,0 @@ -FROM debian:stretch -MAINTAINER Lovell Fuller - -# Create Debian-based container suitable for cross-compiling Linux ARMv8-A binaries - -# Build dependencies -RUN \ - apt-get update && \ - apt-get install -y curl && \ - dpkg --add-architecture arm64 && \ - apt-get update && \ - apt-get install -y crossbuild-essential-arm64 autoconf libtool nasm gtk-doc-tools texinfo advancecomp libglib2.0-dev jq gettext intltool autopoint - -# Compiler settings -ENV \ - PLATFORM=linux-armv8 \ - CHOST=aarch64-linux-gnu \ - FLAGS="-march=armv8-a -Os -D_GLIBCXX_USE_CXX11_ABI=0" diff --git a/packaging/linux-x64/Dockerfile b/packaging/linux-x64/Dockerfile deleted file mode 100644 index 3bf32719..00000000 --- a/packaging/linux-x64/Dockerfile +++ /dev/null @@ -1,16 +0,0 @@ -FROM debian:wheezy -MAINTAINER Lovell Fuller - -# Create Debian-based container suitable for building Linux x64 binaries - -# Build dependencies -RUN \ - echo "deb http://ftp.debian.org/debian wheezy-backports main" | tee /etc/apt/sources.list.d/wheezy-backports.list && \ - apt-get update && \ - apt-get install -y build-essential autoconf libtool nasm gtk-doc-tools texinfo advancecomp && \ - apt-get -t wheezy-backports install -y jq - -# Compiler settings -ENV \ - PLATFORM="linux-x64" \ - FLAGS="-O3" diff --git a/packaging/test-linux-arm.sh b/packaging/test-linux-arm.sh deleted file mode 100755 index c887ac87..00000000 --- a/packaging/test-linux-arm.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/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 pirate@${IP}:/home/pirate/sharp - -echo "Compile and test within container" -sshpass -e ssh -o PreferredAuthentications=password -t pirate@${IP} "docker run --rm -v \${PWD}/sharp:/s hypriot/rpi-node:6 sh -c 'cd /s && npm install --unsafe-perm && npm test'" diff --git a/packaging/test-linux-x64.sh b/packaging/test-linux-x64.sh deleted file mode 100755 index 3d073695..00000000 --- a/packaging/test-linux-x64.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/sh - -# Verify docker is available -if ! type docker >/dev/null; then - echo "Please install docker" - exit 1 -fi - -test="npm run clean; npm install --unsafe-perm; npm test" - -# Debian 7, 8 -# Ubuntu 14.04, 16.04 -for dist in debian:jessie debian:stretch ubuntu:trusty ubuntu:xenial; do - echo "Testing $dist..." - docker pull $dist - if docker run -i -t --rm -v $PWD:/v $dist >packaging/$dist.log 2>&1 sh -c "cd /v; ./packaging/test/debian.sh; $test"; - then echo "$dist OK" - else echo "$dist fail" && cat packaging/$dist.log - fi -done - -# Centos 7 -echo "Testing centos7..." -docker pull centos:7 -if docker run -i -t --rm -v $PWD:/v centos:7 >packaging/centos7.log 2>&1 sh -c "cd /v; ./packaging/test/centos.sh; $test"; -then echo "centos7 OK" -else echo "centos7 fail" && cat packaging/centos7.log -fi - -# Archlinux latest -echo "Testing archlinux..." -docker pull pritunl/archlinux:latest -if docker run -i -t --rm -v $PWD:/v pritunl/archlinux:latest >packaging/archlinux.log 2>&1 sh -c "cd /v; ./packaging/test/archlinux.sh; $test"; -then echo "archlinux OK" -else echo "archlinux fail" && cat packaging/archlinux.log -fi diff --git a/packaging/test/archlinux.sh b/packaging/test/archlinux.sh deleted file mode 100755 index 73afcb8d..00000000 --- a/packaging/test/archlinux.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh - -# Install Node.js on Archlinux -pacman -Sy --noconfirm gcc make python2 nodejs npm | cat -ln -s /usr/bin/python2 /usr/bin/python diff --git a/packaging/test/centos.sh b/packaging/test/centos.sh deleted file mode 100755 index 5a3d63fa..00000000 --- a/packaging/test/centos.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh - -curl -sL https://rpm.nodesource.com/setup_6.x | bash - -yum install -y gcc-c++ make nodejs diff --git a/packaging/test/debian.sh b/packaging/test/debian.sh deleted file mode 100755 index 5c6f9ef9..00000000 --- a/packaging/test/debian.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh - -apt-get update -apt-get install -y build-essential python pkg-config curl -curl -sL https://deb.nodesource.com/setup_6.x | bash - -apt-get install -y nodejs diff --git a/packaging/win32-x64/Dockerfile b/packaging/win32-x64/Dockerfile deleted file mode 100644 index 4c4abade..00000000 --- a/packaging/win32-x64/Dockerfile +++ /dev/null @@ -1,8 +0,0 @@ -FROM debian:stretch -MAINTAINER Lovell Fuller - -# Create Debian-based container suitable for post-processing Windows x64 binaries - -RUN apt-get update && apt-get install -y curl zip advancecomp - -ENV PLATFORM=win32-x64 diff --git a/src/libvips/cplusplus/VImage.cpp b/src/libvips/cplusplus/VImage.cpp index 27b29fdf..93b2e56e 100644 --- a/src/libvips/cplusplus/VImage.cpp +++ b/src/libvips/cplusplus/VImage.cpp @@ -565,34 +565,6 @@ VImage::new_from_buffer( void *buf, size_t len, const char *option_string, return( out ); } -VImage -VImage::new_from_image( std::vector pixel ) -{ - VImage onepx = VImage::black( 1, 1, - VImage::option()->set( "bands", bands() ) ); - - onepx = (onepx + pixel).cast( format() ); - - VImage big = onepx.embed( 0, 0, width(), height(), - VImage::option()->set( "extend", VIPS_EXTEND_COPY ) ); - - big = big.copy( - VImage::option()-> - set( "interpretation", interpretation() )-> - set( "xres", xres() )-> - set( "yres", yres() )-> - set( "xoffset", xres() )-> - set( "yoffset", yres() ) ); - - return( big ); -} - -VImage -VImage::new_from_image( double pixel ) -{ - return( new_from_image( to_vectorv( 1, pixel ) ) ); -} - VImage VImage::new_matrix( int width, int height ) { @@ -693,10 +665,10 @@ VImage::bandsplit( VOption *options ) VImage VImage::bandjoin( VImage other, VOption *options ) { - VImage v[2] = { *this, other }; - std::vector vec( v, v + VIPS_NUMBER( v ) ); + VImage v[2] = { *this, other }; + std::vector vec( v, v + VIPS_NUMBER( v ) ); - return( bandjoin( vec, options ) ); + return( bandjoin( vec, options ) ); } std::complex diff --git a/src/pipeline.cc b/src/pipeline.cc index 972df00f..517b10df 100644 --- a/src/pipeline.cc +++ b/src/pipeline.cc @@ -534,6 +534,9 @@ class PipelineWorker : public Nan::AsyncWorker { // Attention-based or Entropy-based crop image = image.smartcrop(baton->width, baton->height, VImage::option() ->set("interesting", baton->crop == 16 ? VIPS_INTERESTING_ENTROPY : VIPS_INTERESTING_ATTENTION)); + baton->hasCropOffset = true; + baton->cropOffsetLeft = image.xoffset(); + baton->cropOffsetTop = image.yoffset(); } } } @@ -1005,9 +1008,11 @@ class PipelineWorker : public Nan::AsyncWorker { Set(info, New("height").ToLocalChecked(), New(static_cast(height))); Set(info, New("channels").ToLocalChecked(), New(static_cast(baton->channels))); Set(info, New("premultiplied").ToLocalChecked(), New(baton->premultiplied)); - if (baton->cropCalcLeft != -1 && baton->cropCalcLeft != -1) { - Set(info, New("cropCalcLeft").ToLocalChecked(), New(static_cast(baton->cropCalcLeft))); - Set(info, New("cropCalcTop").ToLocalChecked(), New(static_cast(baton->cropCalcTop))); + if (baton->hasCropOffset) { + Set(info, New("cropOffsetLeft").ToLocalChecked(), + New(static_cast(baton->cropOffsetLeft))); + Set(info, New("cropOffsetTop").ToLocalChecked(), + New(static_cast(baton->cropOffsetTop))); } if (baton->bufferOutLength > 0) { diff --git a/src/pipeline.h b/src/pipeline.h index f0fdab51..ccf6a69c 100644 --- a/src/pipeline.h +++ b/src/pipeline.h @@ -62,8 +62,9 @@ struct PipelineBaton { int channels; Canvas canvas; int crop; - int cropCalcLeft; - int cropCalcTop; + bool hasCropOffset; + int cropOffsetLeft; + int cropOffsetTop; bool premultiplied; std::string kernel; std::string interpolator; @@ -145,8 +146,9 @@ struct PipelineBaton { channels(0), canvas(Canvas::CROP), crop(0), - cropCalcLeft(-1), - cropCalcTop(-1), + hasCropOffset(false), + cropOffsetLeft(0), + cropOffsetTop(0), premultiplied(false), centreSampling(false), flatten(false), diff --git a/test/fixtures/expected/crop-strategy-attention.jpg b/test/fixtures/expected/crop-strategy-attention.jpg index 16ddaa166b6958c5c764ea253bc137e85d63a0d2..e9349e606b27e2be75dfd90de25f382ddcbea273 100644 GIT binary patch delta 5796 zcmV;V7F+3}Bcv{nw0{Kx0|W*K0SEy9!~j1K00IF60|5pD1_K5K1poj50RjU61Q7)i zAu$FMB0*7M2XT=UBQipPp%uZ=7Bh0O;qVtyQ)2NXG(%&8|HJ?q0RRI50RaI300000 z0000000IL90R;dC|HJ?!5dZ@K0s#d900IL500000000331Ah@A1QIbpQ4=DeGD2bh z+5ij#0RRFK0}%i}0JdApl@zIl^gQB*>GN(?AkiV?TH&8wfI6f@XHI=;m#jib9AtGh zpz0BW8T7?fZ|y)VKqtzF!IZXT-JpQ05(asx7Hl5f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|5w3xeRkh>1&U4~H$ULdIu7OGR7|SK3 zdXrnmqkl*4oh$+CzIvVM_O}uh#oEc;Xc}_5K=8>UkprDpPv3}Mc3~Pj5}~BaDDc7m z05+r(-FFNO=S+*C)sHX__vuQPVQ-?tOm{JfMWdMIb^riMY3XGG2nLNBjQ;BYDCn5pe`W zM7Or@B;N^EQlJJ4r0hE2^royv0L+OXz|OLyWb`L}x1?wsx5GOJ&)(}qM)ztoyGJJ> ztnNUks8kLw9U3`jC7d>+hruK0DmT8AC;;jQ0kER1o>rC+C4@7MOj~_E80Cr*RS*P_ R@F5r*fGAR5K-2p_|Jjmf7jFOn diff --git a/test/unit/crop.js b/test/unit/crop.js index 9a5a2759..67c2d7bc 100644 --- a/test/unit/crop.js +++ b/test/unit/crop.js @@ -170,6 +170,8 @@ describe('Crop', function () { assert.strictEqual(3, info.channels); assert.strictEqual(80, info.width); assert.strictEqual(320, info.height); + assert.strictEqual(-117, info.cropOffsetLeft); + assert.strictEqual(0, info.cropOffsetTop); fixtures.assertSimilar(fixtures.expected('crop-strategy-entropy.jpg'), data, done); }); }); @@ -184,6 +186,8 @@ describe('Crop', function () { assert.strictEqual(4, info.channels); assert.strictEqual(320, info.width); assert.strictEqual(80, info.height); + assert.strictEqual(0, info.cropOffsetLeft); + assert.strictEqual(-80, info.cropOffsetTop); fixtures.assertSimilar(fixtures.expected('crop-strategy.png'), data, done); }); }); @@ -198,6 +202,8 @@ describe('Crop', function () { assert.strictEqual(4, info.channels); assert.strictEqual(320, info.width); assert.strictEqual(80, info.height); + assert.strictEqual(0, info.cropOffsetLeft); + assert.strictEqual(-80, info.cropOffsetTop); fixtures.assertSimilar(fixtures.expected('crop-strategy.png'), data, done); }); }); @@ -214,6 +220,8 @@ describe('Crop', function () { assert.strictEqual(3, info.channels); assert.strictEqual(80, info.width); assert.strictEqual(320, info.height); + assert.strictEqual(-143, info.cropOffsetLeft); + assert.strictEqual(0, info.cropOffsetTop); fixtures.assertSimilar(fixtures.expected('crop-strategy-attention.jpg'), data, done); }); }); @@ -228,6 +236,8 @@ describe('Crop', function () { assert.strictEqual(4, info.channels); assert.strictEqual(320, info.width); assert.strictEqual(80, info.height); + assert.strictEqual(0, info.cropOffsetLeft); + assert.strictEqual(0, info.cropOffsetTop); fixtures.assertSimilar(fixtures.expected('crop-strategy.png'), data, done); }); }); @@ -242,6 +252,8 @@ describe('Crop', function () { assert.strictEqual(4, info.channels); assert.strictEqual(320, info.width); assert.strictEqual(80, info.height); + assert.strictEqual(0, info.cropOffsetLeft); + assert.strictEqual(0, info.cropOffsetTop); fixtures.assertSimilar(fixtures.expected('crop-strategy.png'), data, done); }); }); diff --git a/test/unit/io.js b/test/unit/io.js index 6898dc0a..6ed91c27 100644 --- a/test/unit/io.js +++ b/test/unit/io.js @@ -808,7 +808,7 @@ describe('Input/output', function () { }); }); - it('Convert SVG to PNG at 300DPI', function (done) { + it.skip('Convert SVG to PNG at 1200DPI', function (done) { sharp(fixtures.inputSvg, { density: 1200 }) .resize(1024) .extract({left: 290, top: 760, width: 40, height: 40})