exiftool-vendored
Advanced tools
Comparing version 17.1.0 to 18.0.0
@@ -28,2 +28,10 @@ # Changelog/Versioning | ||
### v18.0.0 | ||
- 💔 `ReadTask.for()` now takes an options hash, which includes the new `defaultVideosToUTC` option. | ||
- 🐞 Videos now default to UTC, unless there is a `TimeZone`, `OffsetTime`, `OffsetTimeOriginal`, `OffsetTimeDigitized`, or `TimeZoneOffset` tag value. Thanks for the [bug report](https://github.com/photostructure/exiftool-vendored.js/issues/113), @mrbrahman! | ||
- 🌱 ExifTool upgraded to [v12.45](https://exiftool.org/history.html#v12.45). | ||
### v17.1.0 | ||
@@ -30,0 +38,0 @@ |
@@ -126,2 +126,9 @@ /// <reference types="node" /> | ||
/** | ||
* Video file dates are assumed to be in UTC, rather than using timezone | ||
* inference used in images. To disable this default, set this to false. | ||
* | ||
* @see <https://github.com/photostructure/exiftool-vendored.js/issues/113> | ||
*/ | ||
defaultVideosToUTC: boolean; | ||
/** | ||
* `ExifTool` has a shebang line that assumes a valid `perl` is installed at | ||
@@ -167,3 +174,3 @@ * `/usr/bin/perl`. | ||
* @param {string} file the file to extract metadata tags from | ||
* @param {string[]} [args] any additional ExifTool arguments, like "-fast" or | ||
* @param {string[]} [optionalArgs] any additional ExifTool arguments, like "-fast" or | ||
* "-fast2". **Most other arguments will require you to use `readRaw`.** | ||
@@ -178,3 +185,3 @@ * Note that the default is "-fast", so if you want ExifTool to read the | ||
*/ | ||
read<T extends Tags = Tags>(file: string, args?: string[]): Promise<T>; | ||
read<T extends Tags = Tags>(file: string, optionalArgs?: string[]): Promise<T>; | ||
/** | ||
@@ -181,0 +188,0 @@ * Read the tags from `file`, without any post-processing of ExifTool values. |
@@ -120,2 +120,3 @@ "use strict"; | ||
], | ||
defaultVideosToUTC: true, | ||
}); | ||
@@ -178,3 +179,3 @@ /** | ||
* @param {string} file the file to extract metadata tags from | ||
* @param {string[]} [args] any additional ExifTool arguments, like "-fast" or | ||
* @param {string[]} [optionalArgs] any additional ExifTool arguments, like "-fast" or | ||
* "-fast2". **Most other arguments will require you to use `readRaw`.** | ||
@@ -189,4 +190,8 @@ * Note that the default is "-fast", so if you want ExifTool to read the | ||
*/ | ||
read(file, args = ["-fast"]) { | ||
return this.enqueueTask(() => ReadTask_1.ReadTask.for(file, this.options.numericTags, args)); // < no way to know at compile time if we're going to get back a T! | ||
read(file, optionalArgs = ["-fast"]) { | ||
return this.enqueueTask(() => ReadTask_1.ReadTask.for(file, { | ||
optionalArgs, | ||
numericTags: this.options.numericTags, | ||
defaultVideosToUTC: this.options.defaultVideosToUTC, | ||
})); // < no way to know at compile time if we're going to get back a T! | ||
} | ||
@@ -193,0 +198,0 @@ /** |
@@ -0,4 +1,8 @@ | ||
import { ExifToolOptions } from "./ExifTool"; | ||
import { ExifToolTask } from "./ExifToolTask"; | ||
import { Tags } from "./Tags"; | ||
export declare function nullish(s: string | undefined): s is undefined; | ||
export declare type ReadTaskOptions = { | ||
optionalArgs: string[]; | ||
} & Pick<ExifToolOptions, "numericTags" | "defaultVideosToUTC">; | ||
export declare class ReadTask extends ExifToolTask<Tags> { | ||
@@ -8,2 +12,3 @@ #private; | ||
readonly args: string[]; | ||
readonly options: ReadTaskOptions; | ||
private readonly degroup; | ||
@@ -21,5 +26,5 @@ /** May have keys that are group-prefixed */ | ||
private constructor(); | ||
static for(filename: string, numericTags: string[], optionalArgs?: string[]): ReadTask; | ||
static for(filename: string, options: ReadTaskOptions): ReadTask; | ||
toString(): string; | ||
parse(data: string, err?: Error): Tags; | ||
} |
@@ -54,12 +54,13 @@ "use strict"; | ||
]; | ||
const nullishes = ["undef", "null", "undefined"]; | ||
const NullIsh = ["undef", "null", "undefined"]; | ||
function nullish(s) { | ||
return s == null || ((0, String_1.isString)(s) && nullishes.includes(s.trim())); | ||
return s == null || ((0, String_1.isString)(s) && NullIsh.includes(s.trim())); | ||
} | ||
exports.nullish = nullish; | ||
class ReadTask extends ExifToolTask_1.ExifToolTask { | ||
constructor(sourceFile, args) { | ||
constructor(sourceFile, args, options) { | ||
super(args); | ||
this.sourceFile = sourceFile; | ||
this.args = args; | ||
this.options = options; | ||
_ReadTask_instances.add(this); | ||
@@ -75,3 +76,4 @@ /** May have keys that are group-prefixed */ | ||
} | ||
static for(filename, numericTags, optionalArgs = []) { | ||
static for(filename, options) { | ||
var _a, _b; | ||
const sourceFile = _path.resolve(filename); | ||
@@ -81,11 +83,11 @@ const args = [ | ||
"-struct", | ||
...optionalArgs, | ||
...((_a = options.optionalArgs) !== null && _a !== void 0 ? _a : []), | ||
]; | ||
// IMPORTANT: "-all" must be after numeric tag references (first reference | ||
// in wins) | ||
args.push(...numericTags.map((ea) => "-" + ea + "#")); | ||
args.push(...((_b = options.numericTags) !== null && _b !== void 0 ? _b : []).map((ea) => "-" + ea + "#")); | ||
// TODO: Do you need -xmp:all, -all, or -all:all? | ||
args.push("-all", "-charset", "filename=utf8", sourceFile); | ||
// console.log("new ReadTask()", { sourceFile, args }) | ||
return new ReadTask(sourceFile, args); | ||
return new ReadTask(sourceFile, args, options); | ||
} | ||
@@ -174,6 +176,20 @@ toString() { | ||
}, _ReadTask_extractTzOffset = function _ReadTask_extractTzOffset() { | ||
// tzlookup will be the "best" tz, as it will be a proper Zone name (like | ||
// "America/New_York"), rather than just an hour offset. | ||
(0, Maybe_1.map)((0, Maybe_1.firstDefinedThunk)([ | ||
// See https://github.com/photostructure/exiftool-vendored.js/issues/113 | ||
() => { | ||
var _a, _b, _c; | ||
if (((_b = (_a = this._tags) === null || _a === void 0 ? void 0 : _a.MIMEType) === null || _b === void 0 ? void 0 : _b.startsWith("video/")) && | ||
this.options.defaultVideosToUTC === true) { | ||
return ( | ||
// If there is a TimeZone tag, defer to that before defaulting to UTC: | ||
(_c = (0, Timezones_1.extractTzOffsetFromTags)(this._tags)) !== null && _c !== void 0 ? _c : { | ||
tz: "UTC", | ||
src: "defaultVideosToUTC", | ||
}); | ||
} | ||
return; | ||
}, | ||
// If lat/lon is valid, use the tzlookup library, as it will be a proper | ||
// Zone name (like "America/New_York"), rather than just an hour offset. | ||
() => { | ||
if (!this.invalidLatLon && this.lat != null && this.lon != null) { | ||
@@ -180,0 +196,0 @@ try { |
{ | ||
"name": "exiftool-vendored", | ||
"version": "17.1.0", | ||
"version": "18.0.0", | ||
"description": "Efficient, cross-platform access to ExifTool", | ||
@@ -76,4 +76,5 @@ "main": "./dist/ExifTool.js", | ||
"@types/xmldom": "^0.1.31", | ||
"@typescript-eslint/eslint-plugin": "^5.37.0", | ||
"@typescript-eslint/parser": "^5.37.0", | ||
"@typescript-eslint/eslint-plugin": "^5.38.0", | ||
"@typescript-eslint/parser": "^5.38.0", | ||
"@xmldom/xmldom": "^0.8.2", | ||
"chai": "^4.3.6", | ||
@@ -96,5 +97,4 @@ "chai-as-promised": "^7.1.1", | ||
"tmp": "^0.2.1", | ||
"typedoc": "^0.23.14", | ||
"typedoc": "^0.23.15", | ||
"typescript": "~4.8.3", | ||
"@xmldom/xmldom": "^0.8.2", | ||
"xpath": "^0.0.32" | ||
@@ -110,5 +110,5 @@ }, | ||
"optionalDependencies": { | ||
"exiftool-vendored.exe": "12.43.0", | ||
"exiftool-vendored.pl": "12.43.0" | ||
"exiftool-vendored.exe": "12.45.0", | ||
"exiftool-vendored.pl": "12.45.0" | ||
} | ||
} |
# Releasing new versions of `exiftool-vendored` | ||
1. `git clone` this repo, and either | ||
1. `git clone` this repo, and | ||
[exiftool-vendored.pl](https://github.com/photostructure/exiftool-vendored.pl) | ||
or | ||
onto a POSIX machine, and clone | ||
[exiftool-vendored.exe](https://github.com/photostructure/exiftool-vendored.exe) | ||
into a single directory (like `~/src`) | ||
onto a Windows machine. | ||
@@ -21,4 +21,5 @@ 2. On POSIX, in `../exiftool-vendored.pl`: | ||
4. In `exiftool-vendored.pl`: | ||
4. Finally, release `exiftool-vendored`: | ||
1. `cd ../exiftool-vendored.js` | ||
1. `npx ncu -u` | ||
@@ -32,5 +33,5 @@ 1. `yarn install` | ||
1. `yarn test` | ||
1. Verify diffs are reasonable, and `git commit` | ||
1. Verify diffs are reasonable, `git commit` and `git push` | ||
1. Verify [](https://github.com/photostructure/exiftool-vendored.js/actions/workflows/node.js.yml) | ||
1. Update the [CHANGELOG.md](https://github.com/photostructure/exiftool-vendored.js/blob/main/CHANGELOG.md) | ||
1. `npx release-it` |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
418140
7397