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

Would it be possible to make sharp().metadata() contain image size #695

Closed
Vispercept opened this issue Jan 31, 2017 · 4 comments
Closed

Comments

@Vispercept
Copy link

It would be great if one doesn't have to call toBuffer() to gather information about an image size.

Instead of doing something like that:

sharp()
.toBuffer((err, buf, info) => {
  console.log(info.size)
});

it would be great to receive the size as an property when calling sharp().metadata(). The advantage would be that one doesn't have to work on buffers and can instead get the size by using just the stream.

@lovell
Copy link
Owner

lovell commented Jan 31, 2017

Hello, this should be fairly straightforward to add, thank you for the suggestion.

Ideally we would extract and make common the logic currently in pipeline.cc so it can also work with metadata.cc.

sharp().metadata().then( ({ size }) => console.log(size) );

@KaptaanBarbosa
Copy link

I need to create new image with updated metadata and create empty file but how to add updated metadata in new image

@lovell lovell removed the help wanted label Oct 2, 2018
@lovell lovell added this to the v0.21.0 milestone Oct 2, 2018
@lovell
Copy link
Owner

lovell commented Oct 4, 2018

v0.21.0 now available with this feature.

@lovell lovell closed this as completed Oct 4, 2018
@sidequestlegend
Copy link

sidequestlegend commented Oct 18, 2018

@lovell
I'm using "sharp": "^0.21.0" from npm and this property doesn't seem to exist when i read from the filesystem at least:

 sharp('image_path')
    .metadata()
    .then(metadata=>{
        console.log(metadata.size); // undefined
    });

Edit: sorry should raise a new issue.

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

No branches or pull requests

4 participants