Does any one know of a way that I can read file metadata using node.js? For example, I want to read the 'comment' attribute on the 'details' tab of a jpeg file (on a Windows machine). See image below to understand what it is I am trying to read from the file's metadata.
Asked
Active
Viewed 2.6k times
12
-
Well, for this particular file you're seeing EXIF image metadata. There is no generic file metadata, other than what is provided by the OS. What are you trying to do exactly? Just read EXIF for JPEG/TIFF, or something else? – Brad Sep 29 '14 at 02:56
-
I specifically need the 'Comments' field as shown in the image. I don't know if that is provided by EXIF image metadata. I guess this doesn't really need to be related to image files. The 'Comments' field can be an attribute of other file types as well. It just happens that I need to read it from a bunch of image files. – bbeny Sep 29 '14 at 15:06
-
1The comments field can be in other file types' metadata but not all. For images, this data is stored via EXIF. There is no generic metadata. – Brad Sep 29 '14 at 15:08
-
What would be the best way for me to extract this info from EXIF? – bbeny Sep 29 '14 at 15:49
1 Answers
23
There are a lot of NPM packages for reading EXIF data. For example:
https://www.npmjs.org/package/exif-parser
var parser = require('exif-parser').create(buffer);
var result = parser.parse();
console.log(result);

Brad
- 159,648
- 54
- 349
- 530
-
-
Hi Brad, I try the above example in my application and I get `ReferenceError: buffer is not defined`. Is buffer something that I have to define beforehand? – user95227 Aug 25 '15 at 15:17
-
1
-
2does this only applicable to image filetype? how about others like txt or doc? – iCezz May 13 '16 at 07:22
-
@iCezz Text files don't have metadata. Word documents don't use EXIF for metadata. You'll need something else. – Brad May 13 '16 at 17:37
-
-
Can I have a custom HTML file or something with some kind of metadata stored? – Paula Fleck Aug 17 '18 at 14:07
-
-
-
2@oldboy It appears that there are several. https://www.npmjs.com/search?q=exif%20write – Brad Jan 22 '20 at 05:13
-
1i know. thats why im wondering if its possible (and if so how) to get the metadata of ***any file type*** in a windows environment? – oldboy Jan 22 '20 at 06:22
-
-
ok duly noted. is there anything that will allow me to get the extended attributes of font files specifically?? – oldboy Jan 23 '20 at 02:06
-
@oldboy Post a new question, and include what type of font files you're interested in, and what attributes you're looking for. There are many font file formats. – Brad Jan 23 '20 at 03:46
-