diff --git a/docs/changelog.md b/docs/changelog.md index 4ecfb052..8d367216 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -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) diff --git a/lib/input.js b/lib/input.js index 951e1547..71eb0b6b 100644 --- a/lib/input.js +++ b/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 }); }; diff --git a/test/unit/io.js b/test/unit/io.js index e37db7aa..4715f498 100644 --- a/test/unit/io.js +++ b/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();