1

I have a Cloud Function that resizes an image uploaded to Cloud Storage using Sharp. Everything works, but I'm trying to find a way for Sharp to include metadata of the exact height and width of the new image. I could make a new function that uses other npm packages to download the image from the url and get what I want, but I'm curious to know if there is a way for Sharp to do that as well?

Will Hlas
  • 1,241
  • 1
  • 6
  • 14

1 Answers1

3

just include "withMetadata()"

sharp('input.jpg')
  .withMetadata()
  .toFile('output-with-metadata.jpg')
  .then(info => { ... });

you can find the documentation here https://sharp.pixelplumbing.com/api-output#withmetadata

Shiyas
  • 570
  • 5
  • 11