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

.trim().toBuffer() does not produce info response Object offset properties #4085

Closed
3 tasks done
Zirafnik opened this issue Apr 25, 2024 · 2 comments
Closed
3 tasks done
Labels

Comments

@Zirafnik
Copy link

Possible bug

When using .trim().toFile() it will return a metadata object, which includes the trimOffsetLeft and trimOffsetTop properties.

When we instead save to buffer with .trim().toBuffer() no such properties will become available on the response object.

While I am not sure what is happening in the background, I believe that the offset data is available before saving the image (as this data is used in the operation itself) so it should also be available on the final returned object.

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

  • Running npm install sharp completes without error.
  • Running node -e "require('sharp')" completes without error.

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

Are you using the latest version of sharp?

  • I am using the latest version of sharp as reported by npm view sharp dist-tags.latest.
@lovell lovell added question and removed triage labels Apr 25, 2024
@lovell
Copy link
Owner

lovell commented Apr 25, 2024

Did you see the resolveWithObject property of toBuffer()?

https://sharp.pixelplumbing.com/api-output#tobuffer

const { data, info } = await sharp(input).trim().toBuffer({ resolveWithObject: true });
const { trimOffsetLeft, trimOffsetTop } = info;

@Zirafnik
Copy link
Author

Thank your for the answer. I did not realize this would include the info object from .trim(). This now works.

@lovell lovell closed this as completed Apr 26, 2024
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