diff --git a/docs/src/content/docs/changelog.md b/docs/src/content/docs/changelog.md index 5026a602..ef2f78b6 100644 --- a/docs/src/content/docs/changelog.md +++ b/docs/src/content/docs/changelog.md @@ -22,6 +22,9 @@ Requires libvips v8.16.1 [#4387](https://github.com/lovell/sharp/pull/4387) [@Stephen-X](https://github.com/Stephen-X) +* Ensure support for wide-character filenames on Windows (regression in 0.34.0). + [#4391](https://github.com/lovell/sharp/issues/4391) + ### v0.34.1 - 7th April 2025 * TypeScript: Ensure new `autoOrient` property is optional. diff --git a/src/pipeline.cc b/src/pipeline.cc index 21529acf..bb12a400 100644 --- a/src/pipeline.cc +++ b/src/pipeline.cc @@ -1359,7 +1359,8 @@ class PipelineWorker : public Napi::AsyncWorker { // Add file size to info if (baton->formatOut != "dz" || sharp::IsDzZip(baton->fileOut)) { try { - uint32_t const size = static_cast(std::filesystem::file_size(baton->fileOut)); + uint32_t const size = static_cast( + std::filesystem::file_size(std::filesystem::u8path(baton->fileOut))); info.Set("size", size); } catch (...) {} } diff --git a/test/unit/io.js b/test/unit/io.js index 98b96a57..038bfe1f 100644 --- a/test/unit/io.js +++ b/test/unit/io.js @@ -1036,4 +1036,21 @@ describe('Input/output', function () { }); readable.pipe(inPipeline).pipe(badPipeline); }); + + it('supports wide-character filenames', async () => { + const filename = fixtures.path('output.图片.jpg'); + const create = { + width: 8, + height: 8, + channels: 3, + background: 'green' + }; + await sharp({ create }).toFile(filename); + + const { width, height, channels, format } = await sharp(filename).metadata(); + assert.strictEqual(width, 8); + assert.strictEqual(height, 8); + assert.strictEqual(channels, 3); + assert.strictEqual(format, 'jpeg'); + }); });