mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 15:25:07 +01:00
Allow floating point density input (#1362)
Metadata output will still remain integer
This commit is contained in:
committed by
Lovell Fuller
parent
bf3254cb16
commit
7d48a5ccf4
@@ -34,7 +34,7 @@ const is = require('./is');
|
||||
* @param {Number} [options.left] - the pixel offset from the left edge.
|
||||
* @param {Boolean} [options.tile=false] - set to true to repeat the overlay image across the entire image with the given `gravity`.
|
||||
* @param {Boolean} [options.cutout=false] - set to true to apply only the alpha channel of the overlay image to the input image, giving the appearance of one image being cut out of another.
|
||||
* @param {Number} [options.density=72] - integral number representing the DPI for vector overlay image.
|
||||
* @param {Number} [options.density=72] - number representing the DPI for vector overlay image.
|
||||
* @param {Object} [options.raw] - describes overlay when using raw pixel data.
|
||||
* @param {Number} [options.raw.width]
|
||||
* @param {Number} [options.raw.height]
|
||||
|
||||
@@ -96,7 +96,7 @@ const debuglog = util.debuglog('sharp');
|
||||
* @param {Boolean} [options.failOnError=false] - by default apply a "best effort"
|
||||
* to decode images, even if the data is corrupt or invalid. Set this flag to true
|
||||
* if you'd rather halt processing and raise an error when loading invalid images.
|
||||
* @param {Number} [options.density=72] - integral number representing the DPI for vector images.
|
||||
* @param {Number} [options.density=72] - number representing the DPI for vector images.
|
||||
* @param {Number} [options.page=0] - page number to extract for multi-page input (GIF, TIFF)
|
||||
* @param {Object} [options.raw] - describes raw pixel input image data. See `raw()` for pixel ordering.
|
||||
* @param {Number} [options.raw.width]
|
||||
|
||||
@@ -36,7 +36,7 @@ function _createInputDescriptor (input, inputOptions, containerOptions) {
|
||||
}
|
||||
// Density
|
||||
if (is.defined(inputOptions.density)) {
|
||||
if (is.integer(inputOptions.density) && is.inRange(inputOptions.density, 1, 2400)) {
|
||||
if (is.inRange(inputOptions.density, 1, 2400)) {
|
||||
inputDescriptor.density = inputOptions.density;
|
||||
} else {
|
||||
throw new Error('Invalid density (1 to 2400) ' + inputOptions.density);
|
||||
|
||||
Reference in New Issue
Block a user