mirror of
https://github.com/lovell/sharp.git
synced 2025-07-09 10:30:15 +02:00
Minimum version of libvips now 7.40.0 #74
This commit is contained in:
parent
e22d093002
commit
177a4f574c
@ -29,7 +29,7 @@ This module is powered by the blazingly fast [libvips](https://github.com/jcupit
|
|||||||
### Prerequisites
|
### Prerequisites
|
||||||
|
|
||||||
* Node.js v0.10+
|
* Node.js v0.10+
|
||||||
* [libvips](https://github.com/jcupitt/libvips) v7.38.5+ (7.40.12+ recommended)
|
* [libvips](https://github.com/jcupitt/libvips) v7.40.0+ (7.42.0+ recommended)
|
||||||
|
|
||||||
To install the most suitable version of libvips on the following Operating Systems:
|
To install the most suitable version of libvips on the following Operating Systems:
|
||||||
|
|
||||||
@ -214,12 +214,12 @@ sharp(inputBuffer)
|
|||||||
|
|
||||||
Constructor to which further methods are chained. `input`, if present, can be one of:
|
Constructor to which further methods are chained. `input`, if present, can be one of:
|
||||||
|
|
||||||
* Buffer containing JPEG, PNG, WebP or TIFF (libvips 7.40.0+) image data, or
|
* Buffer containing JPEG, PNG, WebP or TIFF image data, or
|
||||||
* String containing the filename of an image, with most major formats supported.
|
* String containing the filename of an image, with most major formats supported.
|
||||||
|
|
||||||
The object returned implements the [stream.Duplex](http://nodejs.org/api/stream.html#stream_class_stream_duplex) class.
|
The object returned implements the [stream.Duplex](http://nodejs.org/api/stream.html#stream_class_stream_duplex) class.
|
||||||
|
|
||||||
JPEG, PNG, WebP or TIFF (libvips 7.40.0+) format image data can be streamed into the object when `input` is not provided.
|
JPEG, PNG, WebP or TIFF format image data can be streamed into the object when `input` is not provided.
|
||||||
|
|
||||||
JPEG, PNG or WebP format image data can be streamed out from this object.
|
JPEG, PNG or WebP format image data can be streamed out from this object.
|
||||||
|
|
||||||
@ -232,7 +232,7 @@ Fast access to image metadata without decoding any compressed image data.
|
|||||||
* `format`: Name of decoder to be used to decompress image data e.g. `jpeg`, `png`, `webp` (for file-based input additionally `tiff` and `magick`)
|
* `format`: Name of decoder to be used to decompress image data e.g. `jpeg`, `png`, `webp` (for file-based input additionally `tiff` and `magick`)
|
||||||
* `width`: Number of pixels wide
|
* `width`: Number of pixels wide
|
||||||
* `height`: Number of pixels high
|
* `height`: Number of pixels high
|
||||||
* `space`: Name of colour space interpretation e.g. `srgb`, `rgb`, `scrgb`, `cmyk`, `lab`, `xyz`, `b-w` [...](https://github.com/jcupitt/libvips/blob/master/libvips/iofuncs/enumtypes.c#L502)
|
* `space`: Name of colour space interpretation e.g. `srgb`, `rgb`, `scrgb`, `cmyk`, `lab`, `xyz`, `b-w` [...](https://github.com/jcupitt/libvips/blob/master/libvips/iofuncs/enumtypes.c#L522)
|
||||||
* `channels`: Number of bands e.g. `3` for sRGB, `4` for CMYK
|
* `channels`: Number of bands e.g. `3` for sRGB, `4` for CMYK
|
||||||
* `hasAlpha`: Boolean indicating the presence of an alpha transparency channel
|
* `hasAlpha`: Boolean indicating the presence of an alpha transparency channel
|
||||||
* `orientation`: Number value of the EXIF Orientation header, if present
|
* `orientation`: Number value of the EXIF Orientation header, if present
|
||||||
|
8
index.js
8
index.js
@ -71,11 +71,9 @@ var Sharp = function(input) {
|
|||||||
(input[0] === 0x89 && input[1] === 0x50) ||
|
(input[0] === 0x89 && input[1] === 0x50) ||
|
||||||
// WebP
|
// WebP
|
||||||
(input[0] === 0x52 && input[1] === 0x49) ||
|
(input[0] === 0x52 && input[1] === 0x49) ||
|
||||||
// TIFF - requires libvips 7.40.0+
|
// TIFF
|
||||||
(semver.gte(libvipsVersion, '7.40.0') && (
|
(input[0] === 0x4D && input[1] === 0x4D && input[2] === 0x00 && (input[3] === 0x2A || input[3] === 0x2B)) ||
|
||||||
(input[0] === 0x4D && input[1] === 0x4D && input[2] === 0x00 && (input[3] === 0x2A || input[3] === 0x2B)) ||
|
(input[0] === 0x49 && input[1] === 0x49 && (input[2] === 0x2A || input[2] === 0x2B) && input[3] === 0x00)
|
||||||
(input[0] === 0x49 && input[1] === 0x49 && (input[2] === 0x2A || input[2] === 0x2B) && input[3] === 0x00)
|
|
||||||
))
|
|
||||||
) {
|
) {
|
||||||
this.options.bufferIn = input;
|
this.options.bufferIn = input;
|
||||||
} else {
|
} else {
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
"Brandon Aaron <hello.brandon@aaron.sh>",
|
"Brandon Aaron <hello.brandon@aaron.sh>",
|
||||||
"Andreas Lind <andreas@one.com>"
|
"Andreas Lind <andreas@one.com>"
|
||||||
],
|
],
|
||||||
"description": "High performance Node.js module to resize JPEG, PNG and WebP 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": "node ./node_modules/istanbul/lib/cli.js cover ./node_modules/mocha/bin/_mocha -- --slow=5000 --timeout=10000 ./test/unit/*.js"
|
"test": "node ./node_modules/istanbul/lib/cli.js cover ./node_modules/mocha/bin/_mocha -- --slow=5000 --timeout=10000 ./test/unit/*.js"
|
||||||
},
|
},
|
||||||
@ -36,8 +36,6 @@
|
|||||||
"embed",
|
"embed",
|
||||||
"libvips",
|
"libvips",
|
||||||
"vips",
|
"vips",
|
||||||
"fast",
|
|
||||||
"buffer",
|
|
||||||
"stream"
|
"stream"
|
||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
@ -5,13 +5,13 @@
|
|||||||
# * Mac OS
|
# * Mac OS
|
||||||
# * Debian Linux
|
# * Debian Linux
|
||||||
# * Debian 7, 8
|
# * Debian 7, 8
|
||||||
# * Ubuntu 12.04, 14.04, 14.10
|
# * Ubuntu 12.04, 14.04, 14.10, 15.04
|
||||||
# * Mint 13, 17
|
# * Mint 13, 17
|
||||||
# * Red Hat Linux
|
# * Red Hat Linux
|
||||||
# * RHEL/Centos/Scientific 6, 7
|
# * RHEL/Centos/Scientific 6, 7
|
||||||
# * Fedora 21, 22
|
# * Fedora 21, 22
|
||||||
|
|
||||||
vips_version_minimum=7.38.5
|
vips_version_minimum=7.40.0
|
||||||
vips_version_latest_major=7.40
|
vips_version_latest_major=7.40
|
||||||
vips_version_latest_minor=11
|
vips_version_latest_minor=11
|
||||||
|
|
||||||
|
@ -34,7 +34,6 @@ namespace sharp {
|
|||||||
unsigned char const MARKER_PNG[] = {0x89, 0x50};
|
unsigned char const MARKER_PNG[] = {0x89, 0x50};
|
||||||
unsigned char const MARKER_WEBP[] = {0x52, 0x49};
|
unsigned char const MARKER_WEBP[] = {0x52, 0x49};
|
||||||
|
|
||||||
#if (VIPS_MAJOR_VERSION >= 7 && VIPS_MINOR_VERSION >= 40)
|
|
||||||
static bool buffer_is_tiff(char *buffer, size_t len) {
|
static bool buffer_is_tiff(char *buffer, size_t len) {
|
||||||
return (
|
return (
|
||||||
len >= 4 && (
|
len >= 4 && (
|
||||||
@ -43,7 +42,6 @@ namespace sharp {
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Determine image format of a buffer.
|
Determine image format of a buffer.
|
||||||
@ -57,10 +55,8 @@ namespace sharp {
|
|||||||
imageType = ImageType::PNG;
|
imageType = ImageType::PNG;
|
||||||
} else if (memcmp(MARKER_WEBP, buffer, 2) == 0) {
|
} else if (memcmp(MARKER_WEBP, buffer, 2) == 0) {
|
||||||
imageType = ImageType::WEBP;
|
imageType = ImageType::WEBP;
|
||||||
#if (VIPS_MAJOR_VERSION >= 7 && VIPS_MINOR_VERSION >= 40)
|
|
||||||
} else if (buffer_is_tiff(static_cast<char*>(buffer), length)) {
|
} else if (buffer_is_tiff(static_cast<char*>(buffer), length)) {
|
||||||
imageType = ImageType::TIFF;
|
imageType = ImageType::TIFF;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return imageType;
|
return imageType;
|
||||||
@ -77,10 +73,8 @@ namespace sharp {
|
|||||||
vips_pngload_buffer(buffer, length, &image, "access", access, NULL);
|
vips_pngload_buffer(buffer, length, &image, "access", access, NULL);
|
||||||
} else if (imageType == ImageType::WEBP) {
|
} else if (imageType == ImageType::WEBP) {
|
||||||
vips_webpload_buffer(buffer, length, &image, "access", access, NULL);
|
vips_webpload_buffer(buffer, length, &image, "access", access, NULL);
|
||||||
#if (VIPS_MAJOR_VERSION >= 7 && VIPS_MINOR_VERSION >= 40)
|
|
||||||
} else if (imageType == ImageType::TIFF) {
|
} else if (imageType == ImageType::TIFF) {
|
||||||
vips_tiffload_buffer(buffer, length, &image, "access", access, NULL);
|
vips_tiffload_buffer(buffer, length, &image, "access", access, NULL);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user