mirror of
https://github.com/lovell/sharp.git
synced 2025-07-09 18:40:16 +02:00
Allow use of toBuffer+toFile w/ same instance #3044
This commit is contained in:
parent
2b01951306
commit
424660278d
@ -6,6 +6,9 @@ Requires libvips v8.12.2
|
|||||||
|
|
||||||
### v0.30.1 - TBD
|
### v0.30.1 - TBD
|
||||||
|
|
||||||
|
* Allow use of `toBuffer` and `toFile` on the same instance.
|
||||||
|
[#3044](https://github.com/lovell/sharp/issues/3044)
|
||||||
|
|
||||||
* Skip shrink-on-load for known libjpeg rounding errors.
|
* Skip shrink-on-load for known libjpeg rounding errors.
|
||||||
[#3066](https://github.com/lovell/sharp/issues/3066)
|
[#3066](https://github.com/lovell/sharp/issues/3066)
|
||||||
|
|
||||||
|
@ -139,6 +139,7 @@ function toBuffer (options, callback) {
|
|||||||
} else if (this.options.resolveWithObject) {
|
} else if (this.options.resolveWithObject) {
|
||||||
this.options.resolveWithObject = false;
|
this.options.resolveWithObject = false;
|
||||||
}
|
}
|
||||||
|
this.options.fileOut = '';
|
||||||
return this._pipeline(is.fn(options) ? options : callback);
|
return this._pipeline(is.fn(options) ? options : callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -328,6 +328,20 @@ describe('Input/output', function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('Allow use of toBuffer and toFile with same instance', async () => {
|
||||||
|
const instance = sharp({
|
||||||
|
create: {
|
||||||
|
width: 8,
|
||||||
|
height: 8,
|
||||||
|
channels: 3,
|
||||||
|
background: 'red'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
await instance.toFile(fixtures.path('output.jpg'));
|
||||||
|
const data = await instance.toBuffer();
|
||||||
|
assert.strictEqual(Buffer.isBuffer(data), true);
|
||||||
|
});
|
||||||
|
|
||||||
it('Fail when output File is input File', function (done) {
|
it('Fail when output File is input File', function (done) {
|
||||||
sharp(fixtures.inputJpg).toFile(fixtures.inputJpg, function (err) {
|
sharp(fixtures.inputJpg).toFile(fixtures.inputJpg, function (err) {
|
||||||
assert(err instanceof Error);
|
assert(err instanceof Error);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user