New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

exiftool-vendored

Package Overview
Dependencies
Maintainers
1
Versions
252
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

exiftool-vendored - npm Package Compare versions

Comparing version 20.0.0 to 21.0.0

11

CHANGELOG.md

@@ -28,2 +28,13 @@ # Changelog/Versioning

### v21.0.0
- 💔 `ExifDateTime.fromDateTime()` now takes an option hash as the second
argument (instead of the second argument being `rawValue`)
- 🐞 `ExifDateTime.milliseconds` will now be `undefined` if the EXIF or ISO
date string did not specify milliseconds, and will no longer render
milliseconds if the `rawValue` did not include millisecond precision.
- 📦 EXIF and ISO dates without specified seconds or milliseconds are now allowed
### v20.0.0

@@ -30,0 +41,0 @@

5

dist/DateTime.d.ts

@@ -12,3 +12,6 @@ import { DateTime } from "luxon";

export declare function isDateOrTime(o: any): o is DateOrTime;
export declare function dateTimeToExif(d: DateTime): string;
export declare function dateTimeToExif(d: DateTime, opts?: {
includeOffset?: boolean;
includeMilliseconds?: boolean;
}): string;
export declare function toExifString(d: DateOrTime): Maybe<string>;

13

dist/DateTime.js

@@ -19,15 +19,18 @@ "use strict";

o instanceof ExifTime_1.ExifTime ||
o instanceof luxon_1.DateTime);
luxon_1.DateTime.isDateTime(o));
}
exports.isDateOrTime = isDateOrTime;
function dateTimeToExif(d) {
return d.toFormat("y:MM:dd HH:mm:ss.u");
function dateTimeToExif(d, opts) {
return d.toFormat("y:MM:dd HH:mm:ss" +
((opts === null || opts === void 0 ? void 0 : opts.includeMilliseconds) === true ? ".u" : "") +
((opts === null || opts === void 0 ? void 0 : opts.includeOffset) === false ? "" : "ZZ"));
}
exports.dateTimeToExif = dateTimeToExif;
function toExifString(d) {
if (d instanceof luxon_1.DateTime) {
var _a;
if (luxon_1.DateTime.isDateTime(d)) {
return dateTimeToExif(d);
}
else {
return d.toExifString();
return (_a = d === null || d === void 0 ? void 0 : d.toExifString) === null || _a === void 0 ? void 0 : _a.call(d);
}

@@ -34,0 +37,0 @@ }

@@ -18,3 +18,3 @@ import { DateTime, DateTimeJSOptions, ToISOTimeOptions, Zone, ZoneOptions } from "luxon";

readonly zoneName?: string | undefined;
static fromISO(iso: string, zone?: Maybe<string>): Maybe<ExifDateTime>;
static fromISO(iso: string, defaultZone?: Maybe<string>): Maybe<ExifDateTime>;
/**

@@ -45,3 +45,6 @@ * Try to parse a date-time string from EXIF. If there is not both a date

static fromExifLoose(text: Maybe<string>, defaultZone?: Maybe<string>): Maybe<ExifDateTime>;
static fromDateTime(dt: DateTime, rawValue?: string): Maybe<ExifDateTime>;
static fromDateTime(dt: DateTime, opts?: {
rawValue?: Maybe<string>;
unsetMilliseconds?: boolean;
}): Maybe<ExifDateTime>;
/**

@@ -70,2 +73,6 @@ * Create an ExifDateTime from a number of milliseconds since the epoch

setZone(zone?: string | Zone, opts?: ZoneOptions): Maybe<ExifDateTime>;
/**
* CAUTION: This instance will inherit the system timezone if this instance
* has an unset zone
*/
toDateTime(): DateTime;

@@ -72,0 +79,0 @@ toEpochSeconds(): number;

@@ -22,2 +22,7 @@ "use strict";

const Timezones_1 = require("./Timezones");
const TimeFmts = [
{ fmt: "HH:mm:ss.u", unsetMilliseconds: false },
{ fmt: "HH:mm:ss", unsetMilliseconds: true },
{ fmt: "HH:mm", unsetMilliseconds: true },
];
/**

@@ -27,3 +32,3 @@ * Encodes an ExifDateTime with an optional tz offset in minutes.

class ExifDateTime {
static fromISO(iso, zone) {
static fromISO(iso, defaultZone) {
if ((0, String_1.blank)(iso) || null != iso.match(/^\d+$/))

@@ -33,13 +38,19 @@ return undefined;

// so we have to do this ourselves:
return this.fromPatterns(iso, [
// if it specifies a zone, use it:
{ fmt: "y-M-d'T'H:m:s.uZZ" },
{ fmt: "y-M-d'T'H:m:sZZ" },
// if it specifies UTC, use it:
{ fmt: "y-M-d'T'H:m:s.u'Z'", zone: "utc" },
{ fmt: "y-M-d'T'H:m:s'Z'", zone: "utc" },
// Otherwise use the default zone:
{ fmt: "y-M-d'T'H:m:s.u", zone },
{ fmt: "y-M-d'T'H:m:s", zone },
]);
const patterns = [];
for (const z of [
{ fmt: "ZZ", zone: undefined },
{ fmt: "'Z'", zone: "UTC" },
{ fmt: "", zone: defaultZone },
]) {
for (const sep of ["'T'", " "]) {
for (const timeFmt of TimeFmts) {
patterns.push({
fmt: `y-M-d${sep}${timeFmt.fmt}${z.fmt}`,
zone: z.zone,
unsetMilliseconds: timeFmt.unsetMilliseconds,
});
}
}
}
return this.fromPatterns(iso, patterns);
}

@@ -72,3 +83,3 @@ /**

// We only want to strip off the TZA if it isn't "UTC" or "Z"
if (null == s.match(/[.\d\s](utc|z)$/i)) {
if (null == s.match(/[.\d\s](UTC|Z)$/)) {
const noTza = s.replace(/ [a-z]{2,5}$/i, "");

@@ -80,3 +91,3 @@ if (noTza !== s)

for (const input of inputs) {
for (const { fmt, zone } of fmts) {
for (const { fmt, zone, unsetMilliseconds } of fmts) {
const dt = luxon_1.DateTime.fromFormat(input, fmt, {

@@ -86,5 +97,10 @@ setZone: true,

});
const edt = ExifDateTime.fromDateTime(dt, s);
if (edt != null)
return edt;
if (dt.isValid) {
const edt = ExifDateTime.fromDateTime(dt, {
rawValue: s,
unsetMilliseconds: unsetMilliseconds !== null && unsetMilliseconds !== void 0 ? unsetMilliseconds : false,
});
if (edt != null)
return edt;
}
}

@@ -109,15 +125,20 @@ }

return undefined;
return ((_a = this.fromPatterns(text, [
// if it specifies a zone, use it:
{ fmt: "y:M:d H:m:s.uZZ" },
{ fmt: "y:M:d H:m:sZZ" },
// if it specifies UTC, use it:
{ fmt: "y:M:d H:m:s.u'Z'", zone: "utc" },
{ fmt: "y:M:d H:m:s'Z'", zone: "utc" },
// Otherwise use the default zone:
{ fmt: "y:M:d H:m:s.u", zone: defaultZone },
{ fmt: "y:M:d H:m:s", zone: defaultZone },
// Not found yet? Maybe it's in ISO format? See
// https://github.com/photostructure/exiftool-vendored.js/issues/71
])) !== null && _a !== void 0 ? _a : this.fromISO(text, defaultZone));
const patterns = [];
for (const z of [
{ fmt: "ZZ", zone: undefined },
{ fmt: "'Z'", zone: "UTC" },
{ fmt: "", zone: defaultZone },
]) {
for (const timeFmt of TimeFmts) {
patterns.push({
fmt: `y:M:d ${timeFmt.fmt}${z.fmt}`,
zone: z.zone,
unsetMilliseconds: timeFmt.unsetMilliseconds,
});
}
}
return ((_a = this.fromPatterns(text, patterns)) !== null && _a !== void 0 ? _a :
// Not found yet? Maybe it's in ISO format? See
// https://github.com/photostructure/exiftool-vendored.js/issues/71
this.fromISO(text, defaultZone));
}

@@ -128,14 +149,16 @@ static fromExifLoose(text, defaultZone) {

const zone = (0, String_1.notBlank)(defaultZone) ? defaultZone : Timezones_1.UnsetZone;
// The following are from actual datestamps seen in the wild:
const formats = [
"MMM d y H:m:s",
"MMM d y, H:m:s",
// Thu Oct 13 00:12:27 2016:
"ccc MMM d H:m:s y",
];
return this.fromPatterns(text, [
// FWIW, the following are from actual datestamps seen in the wild:
{ fmt: "MMM d y H:m:sZZZ" },
{ fmt: "MMM d y H:m:s", zone },
{ fmt: "MMM d y, H:m:sZZZ" },
{ fmt: "MMM d y, H:m:s", zone },
// Thu Oct 13 00:12:27 2016:
{ fmt: "ccc MMM d H:m:s yZZ" },
{ fmt: "ccc MMM d H:m:s y", zone },
...formats.map((fmt) => ({ fmt: fmt + "ZZ" })),
// And the same formats, without offsets with default zone:
...formats.map((fmt) => ({ fmt, zone })),
]);
}
static fromDateTime(dt, rawValue) {
static fromDateTime(dt, opts) {
var _a;

@@ -145,3 +168,5 @@ if (dt == null || !dt.isValid || dt.year === 0 || dt.year === 1) {

}
return new ExifDateTime(dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second, dt.millisecond, dt.offset === Timezones_1.UnsetZoneOffsetMinutes ? undefined : dt.offset, rawValue, ((_a = dt.zone) === null || _a === void 0 ? void 0 : _a.name) === Timezones_1.UnsetZone.name ? undefined : dt.zoneName);
return new ExifDateTime(dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second, dt.millisecond === 0 && true === (opts === null || opts === void 0 ? void 0 : opts.unsetMilliseconds)
? undefined
: dt.millisecond, dt.offset === Timezones_1.UnsetZoneOffsetMinutes ? undefined : dt.offset, opts === null || opts === void 0 ? void 0 : opts.rawValue, ((_a = dt.zone) === null || _a === void 0 ? void 0 : _a.name) === Timezones_1.UnsetZone.name ? undefined : dt.zoneName);
}

@@ -162,3 +187,3 @@ /**

// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
return this.fromDateTime(luxon_1.DateTime.fromMillis(millis, (0, Object_1.omit)(options, "rawValue")), options.rawValue);
return this.fromDateTime(luxon_1.DateTime.fromMillis(millis, (0, Object_1.omit)(options, "rawValue")), { rawValue: options.rawValue });
}

@@ -197,3 +222,3 @@ static now(opts = {}) {

...opts,
}), this.rawValue);
}), { rawValue: this.rawValue, unsetMilliseconds: this.millisecond == null });
// We know this will be defined: this is valid, so changing the zone will

@@ -204,2 +229,6 @@ // also be valid.

}
/**
* CAUTION: This instance will inherit the system timezone if this instance
* has an unset zone
*/
toDateTime() {

@@ -233,3 +262,6 @@ var _a;

toExifString() {
return (0, DateTime_1.dateTimeToExif)(this.toDateTime());
return (0, DateTime_1.dateTimeToExif)(this.toDateTime(), {
includeOffset: this.hasZone,
includeMilliseconds: this.millisecond != null,
});
}

@@ -236,0 +268,0 @@ toString() {

{
"name": "exiftool-vendored",
"version": "20.0.0",
"version": "21.0.0",
"description": "Efficient, cross-platform access to ExifTool",

@@ -76,5 +76,5 @@ "main": "./dist/ExifTool.js",

"@types/globule": "^1.1.5",
"@types/he": "^1.1.2",
"@types/he": "^1.2.0",
"@types/mocha": "^10.0.1",
"@types/node": "^18.11.18",
"@types/node": "^18.11.19",
"@types/progress": "^2.0.5",

@@ -81,0 +81,0 @@ "@types/rimraf": "^3.0.2",

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc