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

How to exclude or include specific tags while reading metadata #44

Closed
subbagudipalli opened this issue Feb 23, 2019 · 4 comments
Closed
Labels

Comments

@subbagudipalli
Copy link

subbagudipalli commented Feb 23, 2019

Here is code snippet to create an instance of exif tool. From this command, am expecting only format tag should be returned from the response. However, am getting all tags.

var exiftool_vendored = require("exiftool-vendored")
//const exifTool = new exiftool_vendored.ExifTool()
const exifTool = new exiftool_vendored.ExifTool({ exiftoolArgs: ["-stay_open", "True","-format","-@", "-"] });
console.log(exifTool.options)

However, am getting the response using Exiftool command:
Exiftool -stay_open True -format INDD file path
Response:
Format : application/x-indesign

I would like fetch only below metadata fields to avoid performance issues. I have tried passing only "format" attribute but that didn't work. can you let me know how to exclude or include specific tags?

var includeTags = ['subject',
'document_id',
'original_document_id',
'derived_from_document_id',
'derived_from_original_document_id',
'image*',
'format',
'thumbnail*',
'icc_profile_name',
'color*',
'file_size',
'file_type',
'creator*',
'drm*',
'x_resolution',
'y_resolution',
'file_type_extension',
'file_name']

@mceachen
Copy link
Member

Removing tag values from the result isn't a supported operation.

The current args are simply added to the command, which includes a lot of other required parameters, including -all, which will override any attempt to remove prior tags.

Removing a few tags from a JSON parse call will be inconsequential in overall performance compared to running the perl interpreter in an external process.

@subbagudipalli
Copy link
Author

subbagudipalli commented Feb 24, 2019

one suggestion, can you remove "-all" at the end by default in ReadTask rather it can be passed read method along with "-fast"(["-fast", "-all"]) in ExifTool. Let me know if you have any concerns with this approach.

The issue is, I want to extract only specific attributes but it returns all attributes.

// Comment out below code in readTask
// TODO: Do you need -xmp:all, -all, or -all:all?
//args.push("-all", "-charset", "filename=utf8", sourceFile)

// add -all option in read() method of exifTool
read(file: string, args: string[] = ["-fast", "-all"]): Promise {
return this.enqueueTask(() =>
ReadTask.for(file, this.options.numericTags, args)
)

@mceachen
Copy link
Member

mceachen commented Feb 24, 2019

one suggestion, can you remove "-all" at the end

That will be a breaking change for anyone using the second parameter, so no.

The issue is, I want to extract only specific attributes but it returns all attributes

I'd suggest that your use case is pretty specific--if you don't want all the tags you get from ExifTool, you should consider using a simpler metadata extraction library (that doesn't spawn perl!).

Have you looked at how much time you're trying to save if you fetch the 20-odd tags in your list, rather than the full list? I'd be interested to know if the time saved was even measurable.

If you still want to continue down this path, you'll need to

  1. create a new ReadTask class (you should look at extending either ReadTask, ExifToolTask, or even the base Task class), in your own codebase,
  2. make it do whatever you need it to do, and
  3. use the enqueueTask method.

@photostructure photostructure locked as resolved and limited conversation to collaborators Feb 24, 2019
@photostructure photostructure unlocked this conversation Feb 24, 2019
mceachen added a commit that referenced this issue Feb 27, 2019
@mceachen
Copy link
Member

@subbagudipalli I thought of a way to implement this and not break the API. See https://exiftool-vendored.js.org/classes/exiftool.html#readraw

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

No branches or pull requests

2 participants