mirror of
https://github.com/lovell/sharp.git
synced 2026-02-06 06:36:17 +01:00
Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c4a278ec9c | ||
|
|
658a541f49 | ||
|
|
01435977de | ||
|
|
36ac8828f2 | ||
|
|
9c83d98bbb | ||
|
|
dee9ca3ec2 | ||
|
|
d375327d20 | ||
|
|
09244192e9 | ||
|
|
de333eb02d |
@@ -1,4 +1,4 @@
|
|||||||
os: Visual Studio 2014 CTP4
|
os: Visual Studio 2015
|
||||||
version: "{build}"
|
version: "{build}"
|
||||||
build: off
|
build: off
|
||||||
platform: x64
|
platform: x64
|
||||||
|
|||||||
@@ -74,6 +74,15 @@
|
|||||||
'VCCLCompilerTool': {
|
'VCCLCompilerTool': {
|
||||||
'ExceptionHandling': 1 # /EHsc
|
'ExceptionHandling': 1 # /EHsc
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
'configurations': {
|
||||||
|
'Release': {
|
||||||
|
'msvs_settings': {
|
||||||
|
'VCCLCompilerTool': {
|
||||||
|
'ExceptionHandling': 1,
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,16 @@
|
|||||||
|
|
||||||
### v0.11 - "*knife*"
|
### v0.11 - "*knife*"
|
||||||
|
|
||||||
|
#### v0.11.1 - 12<sup>th</sup> August 2015
|
||||||
|
|
||||||
|
* Silence MSVC warning: "C4530: C++ exception handler used, but unwind semantics are not enabled".
|
||||||
|
[#244](https://github.com/lovell/sharp/pull/244)
|
||||||
|
[@TheThing](https://github.com/TheThing)
|
||||||
|
|
||||||
|
* Suppress gamma correction for input image with alpha transparency.
|
||||||
|
[#249](https://github.com/lovell/sharp/issues/249)
|
||||||
|
[@compeak](https://github.com/compeak)
|
||||||
|
|
||||||
#### v0.11.0 - 15<sup>th</sup> July 2015
|
#### v0.11.0 - 15<sup>th</sup> July 2015
|
||||||
|
|
||||||
* Allow alpha transparency compositing via new `overlayWith` method.
|
* Allow alpha transparency compositing via new `overlayWith` method.
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ libvips and its dependencies on the following Operating Systems:
|
|||||||
* Fedora 21, 22
|
* Fedora 21, 22
|
||||||
* Amazon Linux 2014.09, 2015.03
|
* Amazon Linux 2014.09, 2015.03
|
||||||
* OpenSuse 13
|
* OpenSuse 13
|
||||||
* Mac OS
|
|
||||||
|
|
||||||
run the following as a user with `sudo` access:
|
run the following as a user with `sudo` access:
|
||||||
|
|
||||||
@@ -47,11 +46,31 @@ Add `--with-openslide` to enable OpenSlide support:
|
|||||||
curl -s https://raw.githubusercontent.com/lovell/sharp/master/preinstall.sh | sudo bash -s -- --with-openslide
|
curl -s https://raw.githubusercontent.com/lovell/sharp/master/preinstall.sh | sudo bash -s -- --with-openslide
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### Ubuntu LTS
|
||||||
|
|
||||||
|
libvips v7.40.6 is available via a PPA.
|
||||||
|
|
||||||
|
##### 12.04
|
||||||
|
|
||||||
|
```sh
|
||||||
|
sudo add-apt-repository -y ppa:lovell/precise-backport-vips
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y libvips-dev libgsf-1-dev
|
||||||
|
```
|
||||||
|
|
||||||
|
##### 14.04
|
||||||
|
|
||||||
|
```sh
|
||||||
|
sudo add-apt-repository -y ppa:lovell/trusty-backport-vips
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y libvips-dev libgsf-1-dev
|
||||||
|
```
|
||||||
|
|
||||||
### Mac OS
|
### Mac OS
|
||||||
|
|
||||||
[](https://travis-ci.org/lovell/sharp-osx-ci)
|
[](https://travis-ci.org/lovell/sharp-osx-ci)
|
||||||
|
|
||||||
Manual install via homebrew:
|
Install libvips via homebrew:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
brew install homebrew/science/vips --with-webp --with-graphicsmagick
|
brew install homebrew/science/vips --with-webp --with-graphicsmagick
|
||||||
|
|||||||
@@ -4,11 +4,11 @@ repo_url: https://github.com/lovell/sharp
|
|||||||
site_description: The fastest Node.js module for resizing JPEG, PNG, WebP and TIFF images. Uses the libvips library.
|
site_description: The fastest Node.js module for resizing JPEG, PNG, WebP and TIFF images. Uses the libvips library.
|
||||||
copyright: <a href="https://dimens.io/">dimens.io</a>
|
copyright: <a href="https://dimens.io/">dimens.io</a>
|
||||||
google_analytics: ['UA-13034748-12', 'sharp.dimens.io']
|
google_analytics: ['UA-13034748-12', 'sharp.dimens.io']
|
||||||
theme: flatly
|
theme: readthedocs
|
||||||
dev_addr: 0.0.0.0:10101
|
|
||||||
markdown_extensions:
|
markdown_extensions:
|
||||||
- toc:
|
- toc:
|
||||||
permalink: " ♯"
|
permalink: True
|
||||||
|
dev_addr: 0.0.0.0:10101
|
||||||
pages:
|
pages:
|
||||||
- Home: index.md
|
- Home: index.md
|
||||||
- Installation: install.md
|
- Installation: install.md
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "sharp",
|
"name": "sharp",
|
||||||
"version": "0.11.0",
|
"version": "0.11.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>",
|
||||||
@@ -51,7 +51,7 @@
|
|||||||
"semver": "^5.0.1"
|
"semver": "^5.0.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"async": "^1.3.0",
|
"async": "^1.4.2",
|
||||||
"coveralls": "^2.11.2",
|
"coveralls": "^2.11.2",
|
||||||
"exif-reader": "1.0.0",
|
"exif-reader": "1.0.0",
|
||||||
"icc": "^0.0.2",
|
"icc": "^0.0.2",
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
# Ensures libvips is installed and attempts to install it if not
|
# Ensures libvips is installed and attempts to install it if not
|
||||||
# Currently supports:
|
# Currently supports:
|
||||||
# * Mac OS
|
|
||||||
# * Debian Linux
|
# * Debian Linux
|
||||||
# * Debian 7, 8
|
# * Debian 7, 8
|
||||||
# * Ubuntu 12.04, 14.04, 14.10, 15.04
|
# * Ubuntu 12.04, 14.04, 14.10, 15.04
|
||||||
@@ -10,7 +9,7 @@
|
|||||||
# * Red Hat Linux
|
# * Red Hat Linux
|
||||||
# * RHEL/Centos/Scientific 6, 7
|
# * RHEL/Centos/Scientific 6, 7
|
||||||
# * Fedora 21, 22
|
# * Fedora 21, 22
|
||||||
# * Amazon Linux 2014.09
|
# * Amazon Linux 2014.09, 2015.03
|
||||||
|
|
||||||
vips_version_minimum=7.40.0
|
vips_version_minimum=7.40.0
|
||||||
vips_version_latest_major_minor=8.0
|
vips_version_latest_major_minor=8.0
|
||||||
@@ -55,8 +54,7 @@ sorry() {
|
|||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
pkg_config_path_homebrew=`which brew >/dev/null 2>&1 && eval $(brew --env) && echo $PKG_CONFIG_LIBDIR || true`
|
pkg_config_path="$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig:/usr/lib/pkgconfig"
|
||||||
pkg_config_path="$pkg_config_path_homebrew:$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig:/usr/lib/pkgconfig"
|
|
||||||
|
|
||||||
check_if_library_exists() {
|
check_if_library_exists() {
|
||||||
PKG_CONFIG_PATH=$pkg_config_path pkg-config --exists $1
|
PKG_CONFIG_PATH=$pkg_config_path pkg-config --exists $1
|
||||||
@@ -122,21 +120,6 @@ fi
|
|||||||
# OS-specific installations of libopenslide follows
|
# OS-specific installations of libopenslide follows
|
||||||
# Either openslide does not exist, or vips is installed without openslide support
|
# Either openslide does not exist, or vips is installed without openslide support
|
||||||
if [ $enable_openslide -eq 1 ] && [ -z $vips_with_openslide ] && [ $openslide_exists -eq 0 ]; then
|
if [ $enable_openslide -eq 1 ] && [ -z $vips_with_openslide ] && [ $openslide_exists -eq 0 ]; then
|
||||||
case $(uname -s) in
|
|
||||||
*[Dd]arwin*)
|
|
||||||
# Mac OS
|
|
||||||
echo "Detected Mac OS"
|
|
||||||
if type "brew" > /dev/null; then
|
|
||||||
echo "Installing libopenslide via homebrew"
|
|
||||||
brew install openslide
|
|
||||||
elif type "port" > /dev/null; then
|
|
||||||
echo "Installing libopenslide via MacPorts"
|
|
||||||
port install openslide
|
|
||||||
else
|
|
||||||
sorry "openslide" "Mac OS without homebrew or MacPorts"
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
if [ -f /etc/debian_version ]; then
|
if [ -f /etc/debian_version ]; then
|
||||||
# Debian Linux
|
# Debian Linux
|
||||||
DISTRO=$(lsb_release -c -s)
|
DISTRO=$(lsb_release -c -s)
|
||||||
@@ -147,7 +130,7 @@ if [ $enable_openslide -eq 1 ] && [ -z $vips_with_openslide ] && [ $openslide_ex
|
|||||||
echo "Installing libopenslide via apt-get"
|
echo "Installing libopenslide via apt-get"
|
||||||
apt-get install -y libopenslide-dev
|
apt-get install -y libopenslide-dev
|
||||||
;;
|
;;
|
||||||
trusty|utopic|qiana|rebecca)
|
trusty|utopic|qiana|rebecca|rafaela)
|
||||||
# Ubuntu 14, Mint 17
|
# Ubuntu 14, Mint 17
|
||||||
echo "Installing libopenslide dependencies via apt-get"
|
echo "Installing libopenslide dependencies via apt-get"
|
||||||
apt-get install -y automake build-essential curl zlib1g-dev libopenjpeg-dev libpng12-dev libjpeg-dev libtiff5-dev libgdk-pixbuf2.0-dev libxml2-dev libsqlite3-dev libcairo2-dev libglib2.0-dev sqlite3 libsqlite3-dev
|
apt-get install -y automake build-essential curl zlib1g-dev libopenjpeg-dev libpng12-dev libjpeg-dev libtiff5-dev libgdk-pixbuf2.0-dev libxml2-dev libsqlite3-dev libcairo2-dev libglib2.0-dev sqlite3 libsqlite3-dev
|
||||||
@@ -217,32 +200,11 @@ if [ $enable_openslide -eq 1 ] && [ -z $vips_with_openslide ] && [ $openslide_ex
|
|||||||
# Unsupported OS
|
# Unsupported OS
|
||||||
sorry "openslide" "$(uname -a)"
|
sorry "openslide" "$(uname -a)"
|
||||||
fi
|
fi
|
||||||
;;
|
|
||||||
esac
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# OS-specific installations of libvips follows
|
# OS-specific installations of libvips follows
|
||||||
|
|
||||||
case $(uname -s) in
|
if [ -f /etc/debian_version ]; then
|
||||||
*[Dd]arwin*)
|
|
||||||
# Mac OS
|
|
||||||
echo "Detected Mac OS"
|
|
||||||
if type "brew" > /dev/null; then
|
|
||||||
echo "Installing libvips via homebrew"
|
|
||||||
if [ $enable_openslide -eq 1 ]; then
|
|
||||||
brew install homebrew/science/vips --with-webp --with-graphicsmagick --with-openslide
|
|
||||||
else
|
|
||||||
brew install homebrew/science/vips --with-webp --with-graphicsmagick
|
|
||||||
fi
|
|
||||||
elif type "port" > /dev/null; then
|
|
||||||
echo "Installing libvips via MacPorts"
|
|
||||||
port install vips
|
|
||||||
else
|
|
||||||
sorry "vips" "Mac OS without homebrew or MacPorts"
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
if [ -f /etc/debian_version ]; then
|
|
||||||
# Debian Linux
|
# Debian Linux
|
||||||
DISTRO=$(lsb_release -c -s)
|
DISTRO=$(lsb_release -c -s)
|
||||||
echo "Detected Debian Linux '$DISTRO'"
|
echo "Detected Debian Linux '$DISTRO'"
|
||||||
@@ -257,7 +219,7 @@ case $(uname -s) in
|
|||||||
apt-get install -y libvips-dev libgsf-1-dev
|
apt-get install -y libvips-dev libgsf-1-dev
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
trusty|utopic|qiana|rebecca)
|
trusty|utopic|qiana|rebecca|rafaela)
|
||||||
# Ubuntu 14, Mint 17
|
# Ubuntu 14, Mint 17
|
||||||
echo "Installing libvips dependencies via apt-get"
|
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
|
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
|
||||||
@@ -276,7 +238,7 @@ case $(uname -s) in
|
|||||||
sorry "vips" "Debian-based $DISTRO"
|
sorry "vips" "Debian-based $DISTRO"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
elif [ -f /etc/redhat-release ]; then
|
elif [ -f /etc/redhat-release ]; then
|
||||||
# Red Hat Linux
|
# Red Hat Linux
|
||||||
RELEASE=$(cat /etc/redhat-release)
|
RELEASE=$(cat /etc/redhat-release)
|
||||||
echo "Detected Red Hat Linux '$RELEASE'"
|
echo "Detected Red Hat Linux '$RELEASE'"
|
||||||
@@ -317,7 +279,7 @@ case $(uname -s) in
|
|||||||
sorry "vips" "$RELEASE"
|
sorry "vips" "$RELEASE"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
elif [ -f /etc/system-release ]; then
|
elif [ -f /etc/system-release ]; then
|
||||||
# Probably Amazon Linux
|
# Probably Amazon Linux
|
||||||
RELEASE=$(cat /etc/system-release)
|
RELEASE=$(cat /etc/system-release)
|
||||||
case $RELEASE in
|
case $RELEASE in
|
||||||
@@ -334,7 +296,7 @@ case $(uname -s) in
|
|||||||
sorry "vips" "$RELEASE"
|
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)
|
||||||
echo "Detected OpenSuse Linux '$RELEASE'"
|
echo "Detected OpenSuse Linux '$RELEASE'"
|
||||||
case $RELEASE in
|
case $RELEASE in
|
||||||
@@ -345,7 +307,7 @@ case $(uname -s) in
|
|||||||
install_libvips_from_source
|
install_libvips_from_source
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
elif [ -f /etc/SuSE-brand ]; then
|
elif [ -f /etc/SuSE-brand ]; then
|
||||||
RELEASE=$(cat /etc/SuSE-brand | grep VERSION)
|
RELEASE=$(cat /etc/SuSE-brand | grep VERSION)
|
||||||
echo "Detected OpenSuse Linux '$RELEASE'"
|
echo "Detected OpenSuse Linux '$RELEASE'"
|
||||||
case $RELEASE in
|
case $RELEASE in
|
||||||
@@ -356,9 +318,7 @@ case $(uname -s) in
|
|||||||
install_libvips_from_source
|
install_libvips_from_source
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
else
|
else
|
||||||
# Unsupported OS
|
# Unsupported OS
|
||||||
sorry "vips" "$(uname -a)"
|
sorry "vips" "$(uname -a)"
|
||||||
fi
|
fi
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|||||||
@@ -8,20 +8,20 @@
|
|||||||
// Verify platform and compiler compatibility
|
// Verify platform and compiler compatibility
|
||||||
|
|
||||||
#if (VIPS_MAJOR_VERSION < 7 || (VIPS_MAJOR_VERSION == 7 && VIPS_MINOR_VERSION < 40))
|
#if (VIPS_MAJOR_VERSION < 7 || (VIPS_MAJOR_VERSION == 7 && VIPS_MINOR_VERSION < 40))
|
||||||
#error libvips version 7.40.0+ required - see https://github.com/lovell/sharp#prerequisites
|
#error libvips version 7.40.0+ required - see http://sharp.dimens.io/page/install
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef _WIN64
|
#ifdef _WIN64
|
||||||
#error Windows 64-bit is currently unsupported - see https://github.com/lovell/sharp#windows
|
#error Windows 64-bit is currently unsupported - see http://sharp.dimens.io/page/install#windows
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if ((!defined(__clang__)) && defined(__GNUC__) && (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 6)))
|
#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
|
#error GCC version 4.6+ is required for C++11 features - see http://sharp.dimens.io/page/install#prerequisites
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (defined(__clang__) && defined(__has_feature))
|
#if (defined(__clang__) && defined(__has_feature))
|
||||||
#if (!__has_feature(cxx_range_for))
|
#if (!__has_feature(cxx_range_for))
|
||||||
#error clang version 3.0+ is required for C++11 features - see https://github.com/lovell/sharp#prerequisites
|
#error clang version 3.0+ is required for C++11 features - see http://sharp.dimens.io/page/install#prerequisites
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -445,7 +445,7 @@ class PipelineWorker : public NanAsyncWorker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Gamma encoding (darken)
|
// Gamma encoding (darken)
|
||||||
if (baton->gamma >= 1 && baton->gamma <= 3) {
|
if (baton->gamma >= 1 && baton->gamma <= 3 && !HasAlpha(image)) {
|
||||||
VipsImage *gammaEncoded;
|
VipsImage *gammaEncoded;
|
||||||
if (vips_gamma(image, &gammaEncoded, "exponent", 1.0 / baton->gamma, NULL)) {
|
if (vips_gamma(image, &gammaEncoded, "exponent", 1.0 / baton->gamma, NULL)) {
|
||||||
return Error();
|
return Error();
|
||||||
@@ -495,9 +495,8 @@ class PipelineWorker : public NanAsyncWorker {
|
|||||||
bool shouldAffineTransform = xresidual != 0.0 || yresidual != 0.0;
|
bool shouldAffineTransform = xresidual != 0.0 || yresidual != 0.0;
|
||||||
bool shouldBlur = baton->blurSigma != 0.0;
|
bool shouldBlur = baton->blurSigma != 0.0;
|
||||||
bool shouldSharpen = baton->sharpenRadius != 0;
|
bool shouldSharpen = baton->sharpenRadius != 0;
|
||||||
bool shouldTransform = shouldAffineTransform || shouldBlur || shouldSharpen;
|
|
||||||
bool hasOverlay = !baton->overlayPath.empty();
|
bool hasOverlay = !baton->overlayPath.empty();
|
||||||
bool shouldPremultiplyAlpha = HasAlpha(image) && image->Bands == 4 && (shouldTransform || hasOverlay);
|
bool shouldPremultiplyAlpha = HasAlpha(image) && (shouldAffineTransform || shouldBlur || shouldSharpen || hasOverlay);
|
||||||
|
|
||||||
// Premultiply image alpha channel before all transformations to avoid
|
// Premultiply image alpha channel before all transformations to avoid
|
||||||
// dark fringing around bright pixels
|
// dark fringing around bright pixels
|
||||||
@@ -698,25 +697,6 @@ class PipelineWorker : public NanAsyncWorker {
|
|||||||
image = sharpened;
|
image = sharpened;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gamma decoding (brighten)
|
|
||||||
if (baton->gamma >= 1 && baton->gamma <= 3) {
|
|
||||||
VipsImage *gammaDecoded;
|
|
||||||
if (vips_gamma(image, &gammaDecoded, "exponent", baton->gamma, NULL)) {
|
|
||||||
return Error();
|
|
||||||
}
|
|
||||||
vips_object_local(hook, gammaDecoded);
|
|
||||||
image = gammaDecoded;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Apply normalization - stretch luminance to cover full dynamic range
|
|
||||||
if (baton->normalize) {
|
|
||||||
VipsImage *normalized;
|
|
||||||
if (Normalize(hook, image, &normalized)) {
|
|
||||||
return Error();
|
|
||||||
}
|
|
||||||
image = normalized;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Composite with overlay, if present
|
// Composite with overlay, if present
|
||||||
if (hasOverlay) {
|
if (hasOverlay) {
|
||||||
VipsImage *overlayImage = NULL;
|
VipsImage *overlayImage = NULL;
|
||||||
@@ -789,6 +769,25 @@ class PipelineWorker : public NanAsyncWorker {
|
|||||||
image = imageUnpremultiplied;
|
image = imageUnpremultiplied;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Gamma decoding (brighten)
|
||||||
|
if (baton->gamma >= 1 && baton->gamma <= 3 && !HasAlpha(image)) {
|
||||||
|
VipsImage *gammaDecoded;
|
||||||
|
if (vips_gamma(image, &gammaDecoded, "exponent", baton->gamma, NULL)) {
|
||||||
|
return Error();
|
||||||
|
}
|
||||||
|
vips_object_local(hook, gammaDecoded);
|
||||||
|
image = gammaDecoded;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply normalization - stretch luminance to cover full dynamic range
|
||||||
|
if (baton->normalize) {
|
||||||
|
VipsImage *normalized;
|
||||||
|
if (Normalize(hook, image, &normalized)) {
|
||||||
|
return Error();
|
||||||
|
}
|
||||||
|
image = normalized;
|
||||||
|
}
|
||||||
|
|
||||||
// Convert image to sRGB, if not already
|
// Convert image to sRGB, if not already
|
||||||
if (image->Type != VIPS_INTERPRETATION_sRGB) {
|
if (image->Type != VIPS_INTERPRETATION_sRGB) {
|
||||||
// Switch interpretation to sRGB
|
// Switch interpretation to sRGB
|
||||||
|
|||||||
@@ -9,14 +9,14 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"imagemagick": "^0.1.3",
|
"imagemagick": "^0.1.3",
|
||||||
"imagemagick-native": "mash/node-imagemagick-native",
|
"imagemagick-native": "^1.8.0",
|
||||||
"gm": "^1.18.1",
|
"gm": "^1.18.1",
|
||||||
"lwip": "^0.0.7",
|
"lwip": "^0.0.7",
|
||||||
"async": "^1.3.0",
|
"async": "^1.4.2",
|
||||||
"semver": "^4.3.6",
|
"semver": "^5.0.1",
|
||||||
"benchmark": "^1.0.0"
|
"benchmark": "^1.0.0"
|
||||||
},
|
},
|
||||||
"license": "Apache 2.0",
|
"license": "Apache-2.0",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=0.10"
|
"node": ">=0.10"
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
test/fixtures/expected/embed-enlarge.png
vendored
Normal file
BIN
test/fixtures/expected/embed-enlarge.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 813 B |
BIN
test/fixtures/expected/gamma-0.0.jpg
vendored
Normal file
BIN
test/fixtures/expected/gamma-0.0.jpg
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 377 B |
BIN
test/fixtures/expected/gamma-2.2.jpg
vendored
Normal file
BIN
test/fixtures/expected/gamma-2.2.jpg
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.0 KiB |
BIN
test/fixtures/expected/gamma-3.0.jpg
vendored
Normal file
BIN
test/fixtures/expected/gamma-3.0.jpg
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.3 KiB |
BIN
test/fixtures/expected/gamma-alpha.jpg
vendored
Normal file
BIN
test/fixtures/expected/gamma-alpha.jpg
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.1 KiB |
@@ -68,4 +68,18 @@ describe('Embed', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('Enlarge and embed', function(done) {
|
||||||
|
sharp(fixtures.inputPngWithOneColor)
|
||||||
|
.embed()
|
||||||
|
.resize(320, 240)
|
||||||
|
.toBuffer(function(err, data, info) {
|
||||||
|
if (err) throw err;
|
||||||
|
assert.strictEqual(true, data.length > 0);
|
||||||
|
assert.strictEqual('png', info.format);
|
||||||
|
assert.strictEqual(320, info.width);
|
||||||
|
assert.strictEqual(240, info.height);
|
||||||
|
fixtures.assertSimilar(fixtures.expected('embed-enlarge.png'), data, done);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -12,32 +12,53 @@ describe('Gamma correction', function() {
|
|||||||
it('value of 0.0 (disabled)', function(done) {
|
it('value of 0.0 (disabled)', function(done) {
|
||||||
sharp(fixtures.inputJpgWithGammaHoliness)
|
sharp(fixtures.inputJpgWithGammaHoliness)
|
||||||
.resize(129, 111)
|
.resize(129, 111)
|
||||||
.toFile(fixtures.path('output.gamma-0.0.jpg'), done);
|
.toBuffer(function(err, data, info) {
|
||||||
|
assert.strictEqual('jpeg', info.format);
|
||||||
|
assert.strictEqual(129, info.width);
|
||||||
|
assert.strictEqual(111, info.height);
|
||||||
|
fixtures.assertSimilar(fixtures.expected('gamma-0.0.jpg'), data, done);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('value of 2.2 (default)', function(done) {
|
it('value of 2.2 (default)', function(done) {
|
||||||
sharp(fixtures.inputJpgWithGammaHoliness)
|
sharp(fixtures.inputJpgWithGammaHoliness)
|
||||||
.resize(129, 111)
|
.resize(129, 111)
|
||||||
.gamma()
|
.gamma()
|
||||||
.toFile(fixtures.path('output.gamma-2.2.jpg'), done);
|
.toBuffer(function(err, data, info) {
|
||||||
|
assert.strictEqual('jpeg', info.format);
|
||||||
|
assert.strictEqual(129, info.width);
|
||||||
|
assert.strictEqual(111, info.height);
|
||||||
|
fixtures.assertSimilar(fixtures.expected('gamma-2.2.jpg'), data, done);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('value of 3.0', function(done) {
|
it('value of 3.0', function(done) {
|
||||||
sharp(fixtures.inputJpgWithGammaHoliness)
|
sharp(fixtures.inputJpgWithGammaHoliness)
|
||||||
.resize(129, 111)
|
.resize(129, 111)
|
||||||
.gamma(3)
|
.gamma(3)
|
||||||
.toFile(fixtures.path('output.gamma-3.0.jpg'), done);
|
.toBuffer(function(err, data, info) {
|
||||||
|
assert.strictEqual('jpeg', info.format);
|
||||||
|
assert.strictEqual(129, info.width);
|
||||||
|
assert.strictEqual(111, info.height);
|
||||||
|
fixtures.assertSimilar(fixtures.expected('gamma-3.0.jpg'), data, done);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('invalid value', function(done) {
|
it('alpha transparency', function(done) {
|
||||||
var isValid = true;
|
sharp(fixtures.inputPngOverlayLayer1)
|
||||||
try {
|
.resize(320)
|
||||||
|
.gamma()
|
||||||
|
.toBuffer(function(err, data, info) {
|
||||||
|
assert.strictEqual('png', info.format);
|
||||||
|
assert.strictEqual(320, info.width);
|
||||||
|
fixtures.assertSimilar(fixtures.expected('gamma-alpha.jpg'), data, done);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('invalid value', function() {
|
||||||
|
assert.throws(function() {
|
||||||
sharp(fixtures.inputJpgWithGammaHoliness).gamma(4);
|
sharp(fixtures.inputJpgWithGammaHoliness).gamma(4);
|
||||||
} catch (err) {
|
});
|
||||||
isValid = false;
|
|
||||||
}
|
|
||||||
assert.strictEqual(false, isValid);
|
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user