mirror of
https://github.com/lovell/sharp.git
synced 2026-02-05 14:16:17 +01:00
Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
75d72cfded | ||
|
|
21b0d8c7f7 | ||
|
|
fa8f06f07d | ||
|
|
e07a105b7c | ||
|
|
4f72dcbf54 | ||
|
|
b77877c83d | ||
|
|
8fd3520257 | ||
|
|
f15e64039c | ||
|
|
3ffe2ba17f | ||
|
|
33782d3c83 | ||
|
|
783826aa26 | ||
|
|
c2ef16eac2 |
@@ -6,3 +6,4 @@ coverage
|
|||||||
.gitignore
|
.gitignore
|
||||||
test
|
test
|
||||||
.travis.yml
|
.travis.yml
|
||||||
|
appveyor.yml
|
||||||
|
|||||||
@@ -2,7 +2,8 @@ language: node_js
|
|||||||
node_js:
|
node_js:
|
||||||
- "0.10"
|
- "0.10"
|
||||||
- "0.12"
|
- "0.12"
|
||||||
- iojs
|
- "iojs-v1"
|
||||||
|
- "iojs-v2"
|
||||||
before_install:
|
before_install:
|
||||||
- curl -s https://raw.githubusercontent.com/lovell/sharp/master/preinstall.sh | sudo bash -
|
- curl -s https://raw.githubusercontent.com/lovell/sharp/master/preinstall.sh | sudo bash -
|
||||||
after_success:
|
after_success:
|
||||||
|
|||||||
15
appveyor.yml
15
appveyor.yml
@@ -2,9 +2,16 @@ os: Visual Studio 2014 CTP4
|
|||||||
platform: Win32
|
platform: Win32
|
||||||
configuration: Release
|
configuration: Release
|
||||||
environment:
|
environment:
|
||||||
VIPS_VERSION_MAJOR_MINOR: 7.42
|
VIPS_VERSION_MAJOR_MINOR: 8.0
|
||||||
VIPS_VERSION_PATCH: 3
|
VIPS_VERSION_PATCH: 2
|
||||||
VIPS_WARNING: 0
|
VIPS_WARNING: 0
|
||||||
|
matrix:
|
||||||
|
- nodejs_version: "0.10"
|
||||||
|
nodejs_exec: "node"
|
||||||
|
- nodejs_version: "0.12"
|
||||||
|
nodejs_exec: "node"
|
||||||
|
- nodejs_version: "1.0"
|
||||||
|
nodejs_exec: "iojs"
|
||||||
install:
|
install:
|
||||||
- ps: $env:VIPS_VERSION = "$env:VIPS_VERSION_MAJOR_MINOR.$env:VIPS_VERSION_PATCH"
|
- ps: $env:VIPS_VERSION = "$env:VIPS_VERSION_MAJOR_MINOR.$env:VIPS_VERSION_PATCH"
|
||||||
- ps: Write-Output "Fetching http://www.vips.ecs.soton.ac.uk/supported/$env:VIPS_VERSION_MAJOR_MINOR/win32/vips-dev-$env:VIPS_VERSION.zip"
|
- ps: Write-Output "Fetching http://www.vips.ecs.soton.ac.uk/supported/$env:VIPS_VERSION_MAJOR_MINOR/win32/vips-dev-$env:VIPS_VERSION.zip"
|
||||||
@@ -12,7 +19,7 @@ install:
|
|||||||
- ps: Invoke-Expression "& 7z -y x c:\vips-dev-$env:VIPS_VERSION.zip -oc:\ | FIND /V `"ing `""
|
- ps: Invoke-Expression "& 7z -y x c:\vips-dev-$env:VIPS_VERSION.zip -oc:\ | FIND /V `"ing `""
|
||||||
- ps: $env:VIPS_HOME = "c:\vips-dev-$env:VIPS_VERSION"
|
- ps: $env:VIPS_HOME = "c:\vips-dev-$env:VIPS_VERSION"
|
||||||
- ps: $env:PATH = "$env:VIPS_HOME\bin;$env:PATH"
|
- ps: $env:PATH = "$env:VIPS_HOME\bin;$env:PATH"
|
||||||
- ps: Install-Product node 0 x86
|
- ps: Install-Product node $env:nodejs_version x86
|
||||||
- npm install --arch=ia32 --msvs_version=2013
|
- npm install --arch=ia32 --msvs_version=2013
|
||||||
test_script:
|
test_script:
|
||||||
- npm run-script test-win32-node
|
- npm run-script test-win32-%nodejs_exec%
|
||||||
|
|||||||
26
package.json
26
package.json
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "sharp",
|
"name": "sharp",
|
||||||
"version": "0.10.0",
|
"version": "0.10.1",
|
||||||
"author": "Lovell Fuller <npm@lovell.info>",
|
"author": "Lovell Fuller <npm@lovell.info>",
|
||||||
"contributors": [
|
"contributors": [
|
||||||
"Pierre Inglebert <pierre.inglebert@gmail.com>",
|
"Pierre Inglebert <pierre.inglebert@gmail.com>",
|
||||||
@@ -20,9 +20,9 @@
|
|||||||
],
|
],
|
||||||
"description": "High performance Node.js module to resize JPEG, PNG, WebP and TIFF images using the libvips library",
|
"description": "High performance Node.js module to resize JPEG, PNG, WebP and TIFF images using the libvips library",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "VIPS_WARNING=0 node ./node_modules/istanbul/lib/cli.js cover ./node_modules/mocha/bin/_mocha -- --slow=5000 --timeout=15000 ./test/unit/*.js",
|
"test": "VIPS_WARNING=0 node ./node_modules/istanbul/lib/cli.js cover ./node_modules/mocha/bin/_mocha -- --slow=5000 --timeout=20000 ./test/unit/*.js",
|
||||||
"test-win32-node": "node ./node_modules/mocha/bin/mocha --slow=5000 --timeout=15000 ./test/unit/*.js",
|
"test-win32-node": "node ./node_modules/mocha/bin/mocha --slow=5000 --timeout=20000 ./test/unit/*.js",
|
||||||
"test-win32-iojs": "iojs ./node_modules/mocha/bin/mocha --slow=5000 --timeout=15000 ./test/unit/*.js"
|
"test-win32-iojs": "iojs ./node_modules/mocha/bin/mocha --slow=5000 --timeout=20000 ./test/unit/*.js"
|
||||||
},
|
},
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"repository": {
|
"repository": {
|
||||||
@@ -42,21 +42,21 @@
|
|||||||
"vips"
|
"vips"
|
||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"bluebird": "^2.9.24",
|
"bluebird": "^2.9.27",
|
||||||
"color": "^0.8.0",
|
"color": "^0.8.0",
|
||||||
"nan": "^1.7.0",
|
"nan": "^1.8.4",
|
||||||
"semver": "^4.3.3"
|
"semver": "^4.3.6"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"mocha": "^2.2.4",
|
"async": "^1.1.0",
|
||||||
"mocha-jshint": "^2.2.0",
|
|
||||||
"istanbul": "^0.3.13",
|
|
||||||
"coveralls": "^2.11.2",
|
"coveralls": "^2.11.2",
|
||||||
|
"istanbul": "^0.3.14",
|
||||||
|
"mocha": "^2.2.5",
|
||||||
|
"mocha-jshint": "^2.2.3",
|
||||||
"node-cpplint": "^0.4.0",
|
"node-cpplint": "^0.4.0",
|
||||||
"rimraf": "^2.3.2",
|
"rimraf": "^2.3.4"
|
||||||
"async": "^0.9.0"
|
|
||||||
},
|
},
|
||||||
"license": "Apache 2.0",
|
"license": "Apache-2.0",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=0.10"
|
"node": ">=0.10"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,12 +13,12 @@
|
|||||||
# * Amazon Linux 2014.09
|
# * Amazon Linux 2014.09
|
||||||
|
|
||||||
vips_version_minimum=7.40.0
|
vips_version_minimum=7.40.0
|
||||||
vips_version_latest_major_minor=7.42
|
vips_version_latest_major_minor=8.0
|
||||||
vips_version_latest_patch=3
|
vips_version_latest_patch=2
|
||||||
|
|
||||||
openslide_version_minimum=3.4.0
|
openslide_version_minimum=3.4.0
|
||||||
openslide_version_latest_major_minor=3.4
|
openslide_version_latest_major_minor=3.4
|
||||||
openslide_version_latest_patch=0
|
openslide_version_latest_patch=1
|
||||||
|
|
||||||
install_libvips_from_source() {
|
install_libvips_from_source() {
|
||||||
echo "Compiling libvips $vips_version_latest_major_minor.$vips_version_latest_patch from source"
|
echo "Compiling libvips $vips_version_latest_major_minor.$vips_version_latest_patch from source"
|
||||||
@@ -250,11 +250,11 @@ case $(uname -s) in
|
|||||||
jessie|vivid)
|
jessie|vivid)
|
||||||
# Debian 8, Ubuntu 15
|
# Debian 8, Ubuntu 15
|
||||||
if [ $enable_openslide -eq 1 ]; then
|
if [ $enable_openslide -eq 1 ]; then
|
||||||
echo "Installing libvips via apt-get"
|
|
||||||
apt-get install -y libvips-dev libgsf-1-dev
|
|
||||||
else
|
|
||||||
echo "Recompiling vips with openslide support"
|
echo "Recompiling vips with openslide support"
|
||||||
install_libvips_from_source
|
install_libvips_from_source
|
||||||
|
else
|
||||||
|
echo "Installing libvips via apt-get"
|
||||||
|
apt-get install -y libvips-dev libgsf-1-dev
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
trusty|utopic|qiana|rebecca)
|
trusty|utopic|qiana|rebecca)
|
||||||
@@ -321,7 +321,7 @@ case $(uname -s) in
|
|||||||
# Probably Amazon Linux
|
# Probably Amazon Linux
|
||||||
RELEASE=$(cat /etc/system-release)
|
RELEASE=$(cat /etc/system-release)
|
||||||
case $RELEASE in
|
case $RELEASE in
|
||||||
"Amazon Linux AMI release 2014.09")
|
"Amazon Linux AMI release 2014.09"|"Amazon Linux AMI release 2015.03")
|
||||||
# Amazon Linux
|
# Amazon Linux
|
||||||
echo "Detected '$RELEASE'"
|
echo "Detected '$RELEASE'"
|
||||||
echo "Installing libvips dependencies via yum"
|
echo "Installing libvips dependencies via yum"
|
||||||
@@ -329,6 +329,10 @@ case $(uname -s) in
|
|||||||
yum install -y gtk-doc libxml2-devel libjpeg-turbo-devel libpng-devel libtiff-devel libexif-devel libgsf-devel lcms-devel ImageMagick-devel gobject-introspection-devel libwebp-devel curl
|
yum install -y gtk-doc libxml2-devel libjpeg-turbo-devel libpng-devel libtiff-devel libexif-devel libgsf-devel lcms-devel ImageMagick-devel gobject-introspection-devel libwebp-devel curl
|
||||||
install_libvips_from_source "--prefix=/usr"
|
install_libvips_from_source "--prefix=/usr"
|
||||||
;;
|
;;
|
||||||
|
*)
|
||||||
|
# Unsupported Amazon Linux version
|
||||||
|
sorry "vips" "$RELEASE"
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
elif [ -f /etc/os-release ]; then
|
elif [ -f /etc/os-release ]; then
|
||||||
RELEASE=$(cat /etc/os-release | grep VERSION)
|
RELEASE=$(cat /etc/os-release | grep VERSION)
|
||||||
|
|||||||
@@ -1,9 +1,26 @@
|
|||||||
|
#include <cstdlib>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <vips/vips.h>
|
#include <vips/vips.h>
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
|
// Verify platform and compiler compatibility
|
||||||
|
|
||||||
|
#ifdef _WIN64
|
||||||
|
#error Windows 64-bit is currently unsupported - see https://github.com/lovell/sharp#windows
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if ((!defined(__clang__)) && defined(__GNUC__) && (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 6)))
|
||||||
|
#error GCC version 4.6+ is required for C++11 features - see https://github.com/lovell/sharp#prerequisites
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if (defined(__clang__) && defined(__has_feature))
|
||||||
|
#if (!__has_feature(cxx_range_for))
|
||||||
|
#error clang version 3.0+ is required for C++11 features - see https://github.com/lovell/sharp#prerequisites
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace sharp {
|
namespace sharp {
|
||||||
|
|
||||||
// How many tasks are in the queue?
|
// How many tasks are in the queue?
|
||||||
|
|||||||
@@ -593,7 +593,7 @@ class ResizeWorker : public NanAsyncWorker {
|
|||||||
}
|
}
|
||||||
// Create background
|
// Create background
|
||||||
VipsArrayDouble *background;
|
VipsArrayDouble *background;
|
||||||
if (baton->background[3] < 255.0) {
|
if (baton->background[3] < 255.0 || HasAlpha(image)) {
|
||||||
background = vips_array_double_newv(
|
background = vips_array_double_newv(
|
||||||
4, baton->background[0], baton->background[1], baton->background[2], baton->background[3]
|
4, baton->background[0], baton->background[1], baton->background[2], baton->background[3]
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -8,10 +8,6 @@
|
|||||||
#include "resize.h"
|
#include "resize.h"
|
||||||
#include "utilities.h"
|
#include "utilities.h"
|
||||||
|
|
||||||
#ifdef _WIN64
|
|
||||||
#error Windows 64-bit currently unsupported - see https://github.com/lovell/sharp#windows
|
|
||||||
#endif
|
|
||||||
|
|
||||||
extern "C" void init(v8::Handle<v8::Object> target) {
|
extern "C" void init(v8::Handle<v8::Object> target) {
|
||||||
NanScope();
|
NanScope();
|
||||||
vips_init("sharp");
|
vips_init("sharp");
|
||||||
|
|||||||
@@ -50,4 +50,22 @@ describe('Embed', function() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
it('PNG with alpha channel', function(done) {
|
||||||
|
sharp(fixtures.inputPngWithTransparency)
|
||||||
|
.resize(50, 50)
|
||||||
|
.embed()
|
||||||
|
.toBuffer(function(err, data, info) {
|
||||||
|
if (err) throw err;
|
||||||
|
assert.strictEqual(true, data.length > 0);
|
||||||
|
assert.strictEqual('png', info.format);
|
||||||
|
assert.strictEqual(50, info.width);
|
||||||
|
assert.strictEqual(50, info.height);
|
||||||
|
sharp(data).metadata(function(err, metadata) {
|
||||||
|
if (err) throw err;
|
||||||
|
assert.strictEqual(4, metadata.channels);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user