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

Promise support #80

Open
Darker opened this issue Feb 26, 2020 · 3 comments
Open

Promise support #80

Darker opened this issue Feb 26, 2020 · 3 comments

Comments

@Darker
Copy link

Darker commented Feb 26, 2020

It would be nice to have a promisified version of the function. For now, I use this:

function ExifPromise(path) {
    return new Promise(function (resolve, reject) {
        try {
            new ExifImage({ image: path }, function (error, exifData) {
                if (error)
                    reject(error);
                else
                    resolve(exifData);
            });
        } catch (error) {
            reject(error);
        }
    });
}
@mohshbool
Copy link

This is my typescript-ready version of it

import Exif, { ExifImage } from 'exif';

function ExifPromise(path: string | Buffer): Promise<Exif.ExifData> {
  return new Promise(function(resolve, reject) {
    try {
      new ExifImage({ image: path }, function(error, exifData) {
        if (error) reject(error);
        else resolve(exifData);
      });
    } catch (error) {
      reject(error);
    }
  });
}

@lancedolan
Copy link

I came here to create a promise request and BOOM it's the top issue.

@Darker
Copy link
Author

Darker commented May 13, 2021

Hey just a heads up. It turns out this package reads the whole image and is very slow. I am now using fast-exif package.

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

No branches or pull requests

3 participants