Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sharp resize image lost content #4255

Open
yunmc opened this issue Nov 6, 2024 · 2 comments
Open

sharp resize image lost content #4255

yunmc opened this issue Nov 6, 2024 · 2 comments
Labels

Comments

@yunmc
Copy link

yunmc commented Nov 6, 2024

Possible bug

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

System:
OS: Linux 4.19 Debian GNU/Linux 9 (stretch) 9 (stretch)
CPU: (4) x64 AMD EPYC 7T83 64-Core Processor
Memory: 2.57 GB / 15.11 GB
Container: Yes
Shell: 4.4.12 - /bin/bash
Binaries:
Node: 12.22.12 - /usr/local/bin/node
Yarn: 1.22.18 - /usr/local/bin/yarn
npm: 6.14.16 - /usr/local/bin/npm
npmPackages:
sharp: ^0.30.7 => 0.30.7

What is the expected behaviour?

resize the picture while ensuring that the content of the picture is not lost.

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

const image = sharp(buff);
const {
  width,
  height,
} = await image.metadata();
const limit = 2173;
if (Math.min(width, height) > limit) {
  image.resize(width < height ? { width: limit } : { height: limit });
  buff = await image.jpeg({ quality: 100 }).toBuffer();
}

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

before resize: https://sigma-temp.oss-cn-shanghai.aliyuncs.com/temp_image/20241106-102659.jpg

after resize: https://sigma-temp.oss-cn-shanghai.aliyuncs.com/temp_image/20241106-102719.jpg

@yunmc yunmc added the triage label Nov 6, 2024
@lovell lovell added question and removed triage labels Nov 6, 2024
@lovell
Copy link
Owner

lovell commented Nov 6, 2024

Node: 12.22.12 - /usr/local/bin/node
sharp: ^0.30.7 => 0.30.7

Please ensure you're using the latest version of sharp with an active version of Node.js.

If you're still having problems, please provide complete, standalone, minimal code and sample image that allows someone else to reproduce.

@lovell
Copy link
Owner

lovell commented Dec 19, 2024

@yunmc Were you able to make any progress with this? If you still require help, please provide the requested information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants