question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

how to get metadata of output image?

See original GitHub issue

the current example only get input image metadata, not output, if the input image’s size is 1200x1200, we get {width: 1200, height: 1200, ...} not {width: 400, height: ?, ...}

      const sharpInstance = sharp(buf).resize(400);
      const resizedBuf = await sharpInstance.toBuffer();
      const metadata = await sharpInstance.metadata();

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
ajhoolcommented, Aug 2, 2018

Can this be achieved without calling toBuffer? It seems like a common use-case that somebody would need to know the metadata of the transformed file.

0reactions
kghostcommented, Dec 21, 2018

@lovell Eg, I want to convert an unknown sized image to 200*100 with { fit: inside }. after resize call, the size of processed image is unknown, I need to calculate paddings and call extend to extend the image to 200*100.

I don’t know if it is a bug. After

img.resize(200,100,{fit:sharp.fit.inside})

I got an 100*100 image when input is square.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to read and export image metadata with Exiftool
Once installed in your operating system of choice, you will have the ability to use the command line to quickly view and export...
Read more >
Extract Image Metadata with JSON Output Format
Extract Image Metadata with JSON Output Format ... Metadata is a powerful tool when working with images. It can tell you the dimensions...
Read more >
How to extract image metadata in Python? - GeeksforGeeks
Approach: Import the pillow module. Load the image; Get the metadata. The metadata so obtained; Convert it into human-readable form.
Read more >
How to Obtain Valuable Data from Images Using Exif Extractors
To view Exif information, upload a file or add its public URL, then hit “View Exif.” In my example, passing the same photo...
Read more >
How To View Image Metadata On Linux - OSTechNix
ImageMagick has a command line tool named "Identify" to find image metadata. ImageMagick is available in the default repositories of most Linux ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found