From a472aea025052720642b263e647feae0921ba794 Mon Sep 17 00:00:00 2001 From: Lovell Fuller Date: Sun, 20 Nov 2022 21:30:45 +0000 Subject: [PATCH] Ignore sequentialRead option for stats #3462 --- docs/changelog.md | 3 +++ src/stats.cc | 1 + test/unit/stats.js | 5 +++++ 3 files changed, 9 insertions(+) diff --git a/docs/changelog.md b/docs/changelog.md index 986b84b4..e69d779e 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -15,6 +15,9 @@ Requires libvips v8.13.3 * Improve `extractChannel` support for 16-bit output colourspaces. [#3453](https://github.com/lovell/sharp/issues/3453) +* Ignore `sequentialRead` option when calculating image statistics. + [#3462](https://github.com/lovell/sharp/issues/3462) + ### v0.31.2 - 4th November 2022 * Upgrade to libvips v8.13.3 for upstream bug fixes. diff --git a/src/stats.cc b/src/stats.cc index 1d7942b1..5a6a3172 100644 --- a/src/stats.cc +++ b/src/stats.cc @@ -176,6 +176,7 @@ Napi::Value stats(const Napi::CallbackInfo& info) { // Input baton->input = sharp::CreateInputDescriptor(options.Get("input").As()); + baton->input->access = VIPS_ACCESS_RANDOM; // Function to notify of libvips warnings Napi::Function debuglog = options.Get("debuglog").As(); diff --git a/test/unit/stats.js b/test/unit/stats.js index 2a878cb2..fd611777 100644 --- a/test/unit/stats.js +++ b/test/unit/stats.js @@ -730,4 +730,9 @@ describe('Image Stats', function () { done(); }); }); + + it('Sequential read option is ignored', async () => { + const { isOpaque } = await sharp(fixtures.inputJpg, { sequentialRead: true }).stats(); + assert.strictEqual(isOpaque, true); + }); });