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

Error: Given file is neither JPEG nor TIFF. #145

Open
bowencool opened this issue Nov 22, 2023 · 0 comments
Open

Error: Given file is neither JPEG nor TIFF. #145

bowencool opened this issue Nov 22, 2023 · 0 comments

Comments

@bowencool
Copy link

bowencool commented Nov 22, 2023

Codes:

//Node.js v20.9.0, v18.18.2
import { readFile } from "node:fs/promises";
import { load } from "piexifjs";

// ...
  if (fileName.match(/\.(jpg|jpeg|png)$/i)) {
    console.log(RegExp.$1);
    const dataURL = await readFile(filePath, { encoding: "base64" });
    const exifObj = load(`data:image/${RegExp.$1};base64,${dataURL}`);
  }
// ... 

Outputs:

              throw new Error("Given file is neither JPEG nor TIFF.");
                    ^

Error: Given file is neither JPEG nor TIFF.
    at ExifReader (/xxx/node_modules/.pnpm/[email protected]/node_modules/piexifjs/dist/piexif.js:2123:21)

Image:

639__836EF234

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

1 participant