mirror of
https://github.com/lovell/sharp.git
synced 2025-07-11 03:20:13 +02:00
Remove previously deprecated limitInputPixels, sequentialRead
This commit is contained in:
parent
4abb4edf64
commit
c17807c995
@ -6,6 +6,8 @@ Requires libvips TBD
|
||||
|
||||
### v0.25.0 - TBD
|
||||
|
||||
* Remove `limitInputPixels` and `sequentialRead` previously deprecated in v0.24.0.
|
||||
|
||||
* Migrate internals to N-API.
|
||||
[#1282](https://github.com/lovell/sharp/issues/1282)
|
||||
|
||||
|
32
lib/input.js
32
lib/input.js
@ -1,6 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
const util = require('util');
|
||||
const color = require('color');
|
||||
const is = require('./is');
|
||||
const sharp = require('../build/Release/sharp.node');
|
||||
@ -331,32 +330,6 @@ function stats (callback) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
const limitInputPixels = util.deprecate(function limitInputPixels (limit) {
|
||||
// if we pass in false we represent the integer as 0 to disable
|
||||
if (limit === false) {
|
||||
limit = 0;
|
||||
} else if (limit === true) {
|
||||
limit = Math.pow(0x3FFF, 2);
|
||||
}
|
||||
if (is.integer(limit) && limit >= 0) {
|
||||
this.options.input.limitInputPixels = limit;
|
||||
} else {
|
||||
throw is.invalidParameterError('limitInputPixels', 'integer', limit);
|
||||
}
|
||||
return this;
|
||||
}, 'limitInputPixels is deprecated, use sharp(input, { limitInputPixels: false }) instead');
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
const sequentialRead = util.deprecate(function sequentialRead (sequentialRead) {
|
||||
this.options.input.sequentialRead = is.bool(sequentialRead) ? sequentialRead : true;
|
||||
return this;
|
||||
}, 'sequentialRead is deprecated, use sharp(input, { sequentialRead: true }) instead');
|
||||
|
||||
/**
|
||||
* Decorate the Sharp prototype with input-related functions.
|
||||
* @private
|
||||
@ -370,9 +343,6 @@ module.exports = function (Sharp) {
|
||||
_isStreamInput,
|
||||
// Public
|
||||
metadata,
|
||||
stats,
|
||||
// Deprecated
|
||||
limitInputPixels,
|
||||
sequentialRead
|
||||
stats
|
||||
});
|
||||
};
|
||||
|
107
test/unit/io.js
107
test/unit/io.js
@ -234,22 +234,6 @@ describe('Input/output', function () {
|
||||
})
|
||||
);
|
||||
|
||||
it('Sequential read, force JPEG - deprecated', function (done) {
|
||||
sharp(fixtures.inputJpg)
|
||||
.sequentialRead()
|
||||
.resize(320, 240)
|
||||
.toFormat(sharp.format.jpeg)
|
||||
.toBuffer(function (err, data, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual(true, data.length > 0);
|
||||
assert.strictEqual(data.length, info.size);
|
||||
assert.strictEqual('jpeg', info.format);
|
||||
assert.strictEqual(320, info.width);
|
||||
assert.strictEqual(240, info.height);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('Not sequential read, force JPEG', () =>
|
||||
sharp(fixtures.inputJpg, { sequentialRead: false })
|
||||
.resize(320, 240)
|
||||
@ -264,22 +248,6 @@ describe('Input/output', function () {
|
||||
})
|
||||
);
|
||||
|
||||
it('Not sequential read, force JPEG - deprecated', function (done) {
|
||||
sharp(fixtures.inputJpg)
|
||||
.sequentialRead(false)
|
||||
.resize(320, 240)
|
||||
.toFormat('jpeg')
|
||||
.toBuffer(function (err, data, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual(true, data.length > 0);
|
||||
assert.strictEqual(data.length, info.size);
|
||||
assert.strictEqual('jpeg', info.format);
|
||||
assert.strictEqual(320, info.width);
|
||||
assert.strictEqual(240, info.height);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('Support output to jpg format', function (done) {
|
||||
sharp(fixtures.inputPng)
|
||||
.resize(320, 240)
|
||||
@ -653,81 +621,6 @@ describe('Input/output', function () {
|
||||
);
|
||||
});
|
||||
|
||||
describe('Limit pixel count of input image - deprecated', function () {
|
||||
it('Invalid fails - negative', function (done) {
|
||||
let isValid = false;
|
||||
try {
|
||||
sharp().limitInputPixels(-1);
|
||||
isValid = true;
|
||||
} catch (e) {}
|
||||
assert(!isValid);
|
||||
done();
|
||||
});
|
||||
|
||||
it('Invalid fails - float', function (done) {
|
||||
let isValid = false;
|
||||
try {
|
||||
sharp().limitInputPixels(12.3);
|
||||
isValid = true;
|
||||
} catch (e) {}
|
||||
assert(!isValid);
|
||||
done();
|
||||
});
|
||||
|
||||
it('Invalid fails - string', function (done) {
|
||||
let isValid = false;
|
||||
try {
|
||||
sharp().limitInputPixels('fail');
|
||||
isValid = true;
|
||||
} catch (e) {}
|
||||
assert(!isValid);
|
||||
done();
|
||||
});
|
||||
|
||||
it('Same size as input works', function (done) {
|
||||
sharp(fixtures.inputJpg).metadata(function (err, metadata) {
|
||||
if (err) throw err;
|
||||
sharp(fixtures.inputJpg)
|
||||
.limitInputPixels(metadata.width * metadata.height)
|
||||
.toBuffer(function (err) {
|
||||
assert.strictEqual(true, !err);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('Disabling limit works', function (done) {
|
||||
sharp(fixtures.inputJpgLarge)
|
||||
.limitInputPixels(false)
|
||||
.resize(2)
|
||||
.toBuffer(function (err) {
|
||||
assert.strictEqual(true, !err);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('Enabling default limit works and fails with a large image', function (done) {
|
||||
sharp(fixtures.inputJpgLarge)
|
||||
.limitInputPixels(true)
|
||||
.toBuffer(function (err) {
|
||||
assert.strictEqual(true, !!err);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('Smaller than input fails', function (done) {
|
||||
sharp(fixtures.inputJpg).metadata(function (err, metadata) {
|
||||
if (err) throw err;
|
||||
sharp(fixtures.inputJpg)
|
||||
.limitInputPixels((metadata.width * metadata.height) - 1)
|
||||
.toBuffer(function (err) {
|
||||
assert.strictEqual(true, !!err);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Input options', function () {
|
||||
it('Option-less', function () {
|
||||
sharp();
|
||||
|
Loading…
x
Reference in New Issue
Block a user