mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 07:15:08 +01:00
Ensure dimensions of final output image are provided (#399)
Add a failing test for vips::VError exception * fix buffer size mismatch * Loosen error message assertion * Update image
This commit is contained in:
committed by
Lovell Fuller
parent
f214269aa1
commit
ef61da3051
@@ -1031,4 +1031,32 @@ describe('Input/output', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('Info event data', function(done) {
|
||||
var readable = fs.createReadStream(fixtures.inputJPGBig);
|
||||
var inPipeline = sharp()
|
||||
.resize(840)
|
||||
.raw()
|
||||
.on('info', function(info) {
|
||||
assert.strictEqual(840, info.width);
|
||||
assert.strictEqual(472, info.height);
|
||||
assert.strictEqual(3, info.channels);
|
||||
});
|
||||
var badPipeline = sharp(null, {raw: {width: 840, height: 473, channels: 3}})
|
||||
.toFormat('jpeg')
|
||||
.toBuffer(function(err, data, info) {
|
||||
assert.strictEqual(err.message.indexOf('memory area too small') > 0, true);
|
||||
readable = fs.createReadStream(fixtures.inputJPGBig);
|
||||
var goodPipeline = sharp(null, {raw: {width: 840, height: 472, channels: 3}})
|
||||
.toFormat('jpeg')
|
||||
.toBuffer(function(err, data, info) {
|
||||
if (err) throw err;
|
||||
done();
|
||||
});
|
||||
inPipeline = sharp()
|
||||
.resize(840)
|
||||
.raw();
|
||||
readable.pipe(inPipeline).pipe(goodPipeline);
|
||||
});
|
||||
readable.pipe(inPipeline).pipe(badPipeline);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user