lovell / sharp

High performance Node.js image processing, the fastest module to resize JPEG, PNG, WebP, AVIF and TIFF images. Uses the libvips library.
https://sharp.pixelplumbing.com
Apache License 2.0
28.44k stars 1.28k forks source link

Enhancement: add pageHeight to response when generating multi-page output #3411

Open ry0513 opened 1 year ago

ry0513 commented 1 year ago

Possible bug

Is this a possible bug in a feature of sharp, unrelated to installation?

If you cannot confirm both of these, please open an installation issue instead.

Are you using the latest version of sharp?

If you cannot confirm this, please upgrade to the latest version and try again before opening an issue.

If you are using another package which depends on a version of sharp that is not the latest, please open an issue against that package instead.

What is the output of running npx envinfo --binaries --system --npmPackages=sharp --npmGlobalPackages=sharp?

  System:
    OS: Windows 10 10.0.22000
    CPU: (8) x64 Intel(R) Core(TM) i7-9700K CPU @ 3.60GHz
    Memory: 7.28 GB / 15.87 GB
  Binaries:
    Node: 16.14.2 - C:\Program Files\nodejs\node.EXE
    npm: 8.5.0 - C:\Program Files\nodejs\npm.CMD
  npmPackages:
    sharp: ^0.31.1 => 0.31.1

What are the steps to reproduce?

see code example

What is the expected behaviour?

Please see the code example, can I get the height consistent

Please provide a minimal, standalone code sample, without other dependencies, that demonstrates this problem

const sharp = `require("sharp");`

sharp("./1.gif").toFile("./2.gif").then((info) => console.log(info));
// output:
// {
//     format: 'gif',
//     width: 550,
//     height: 400,
//     channels: 3,
//     premultiplied: false,
//     size: 14314
// }

sharp("./1.gif", { animated: true }).toFile("./3.gif").then((info) => console.log(info));
// output:
// {
//     format: 'gif',
//     width: 550,
//     height: 7200,
//     channels: 3,
//     premultiplied: false,
//     size: 562959
// }

Please provide sample image(s) that help explain this problem

1

lovell commented 1 year ago

We should add pageHeight to the info response object when generating multi-page/animated output, to match the naming/behaviour of metadata(). I suspect also adding pages for the page count would be useful too.

https://sharp.pixelplumbing.com/api-input#metadata

ry0513 commented 1 year ago

Thank you, metadata() temporarily solved my problem, still looking forward to info.pageHeight, I wish you a happy day