exifreader 4.11.0 → 4.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -23,7 +23,7 @@ You can try it out on the
23
23
  | ----------|---------|---------|---------|---------|---------|-----------|
24
24
  | JPEG | **yes** | **yes** | **yes** | **yes** | **yes** | **yes** |
25
25
  | TIFF | **yes** | **yes** | **yes** | **yes** | ??? | no |
26
- | PNG | **yes** | no | **yes** | no | no | no |
26
+ | PNG | **yes** | no | **yes** | no | ??? | no |
27
27
  | HEIC/HEIF | **yes** | no | no | **yes** | ??? | no |
28
28
  | WebP | **yes** | no | **yes** | **yes** | ??? | **yes** |
29
29
 
package/exif-reader.d.ts CHANGED
@@ -53,16 +53,22 @@ interface PngFileTags {
53
53
  }
54
54
  }
55
55
 
56
+ interface PngPhysTags {
57
+ 'Pixels Per Unit X'?: NumberFileTag,
58
+ 'Pixels Per Unit Y'?: NumberFileTag,
59
+ 'Pixel Units'?: {
60
+ value: number,
61
+ description: 'meters' | 'Unknown'
62
+ },
63
+ 'Modify Date'?: NumberArrayFileTag
64
+ }
65
+
56
66
  interface PngTag {
57
67
  description: string,
58
68
  value: string | number
59
69
  }
60
70
 
61
- interface PngTags extends PngFileTags {
62
- 'Pixels Per Unit X'?: NumberFileTag
63
- 'Pixels Per Unit Y'?: NumberFileTag
64
- 'Pixel Units'?: 'meters' | 'Unknown'
65
- 'Modify Date'?: NumberArrayFileTag
71
+ type PngTags = PngFileTags & PngPhysTags & {
66
72
  [name: string]: PngTag
67
73
  }
68
74
 
@@ -85,37 +91,27 @@ interface NumberArrayFileTag {
85
91
  value: Array<number>
86
92
  }
87
93
 
88
- interface NumberTag {
94
+ type TypedTag<V> = {
89
95
  id: number,
90
96
  description: string,
91
- value: number
97
+ value: V
92
98
  }
93
99
 
94
- interface RationalTag {
95
- id: number,
96
- description: string,
97
- value: [number, number]
98
- }
100
+ type RationalTag = TypedTag<[number, number]>
99
101
 
100
- interface NumberArrayTag {
101
- id: number,
102
- description: string,
103
- value: Array<number>
104
- }
102
+ type NumberTag = TypedTag<number>;
105
103
 
106
- interface ValueTag {
107
- description: string,
108
- value: String
109
- }
104
+ type NumberArrayTag = TypedTag<number[]>
110
105
 
111
- interface StringArrayTag {
112
- id: number,
106
+ type StringArrayTag = TypedTag<string[]>
107
+
108
+ interface ValueTag {
113
109
  description: string,
114
- value: Array<string>
110
+ value: string
115
111
  }
116
112
 
117
113
  interface XmpTag {
118
- value: string | Array<XmpTag> | XmpTags,
114
+ value: string | XmpTag[] | XmpTags,
119
115
  attributes: {
120
116
  [name: string]: string
121
117
  },
@@ -153,8 +149,8 @@ interface ExpandedTags {
153
149
  pngFile?: PngFileTags,
154
150
  pngText?: PngTextTags,
155
151
  png?: PngTags,
156
- exif?: Tags,
157
- iptc?: Tags,
152
+ exif?: ExifTags,
153
+ iptc?: ExifTags,
158
154
  xmp?: { _raw: string } & XmpTags,
159
155
  icc?: IccTags,
160
156
  Thumbnail?: ThumbnailTags,
@@ -169,7 +165,7 @@ interface GpsTags {
169
165
 
170
166
  interface MPFImageTags {
171
167
  ImageFlags: {
172
- value: Array<number>,
168
+ value: number[],
173
169
  description: string
174
170
  },
175
171
  ImageFormat: {
@@ -200,21 +196,21 @@ interface MPFImageTags {
200
196
  base64: string
201
197
  }
202
198
 
203
- export function load(data: ArrayBuffer | SharedArrayBuffer | Buffer): Tags & XmpTags & IccTags;
199
+ export function load(data: ArrayBuffer | SharedArrayBuffer | Buffer): Tags;
204
200
  export function load(data: ArrayBuffer | SharedArrayBuffer | Buffer, options: {expanded: true, includeUnknown?: boolean, length?: number}): ExpandedTags;
205
- export function load(data: ArrayBuffer | SharedArrayBuffer | Buffer, options: {expanded?: false, includeUnknown?: boolean, length?: number}): Tags & XmpTags & IccTags;
206
- export function load(data: string | File): Promise<Tags & XmpTags & IccTags>;
201
+ export function load(data: ArrayBuffer | SharedArrayBuffer | Buffer, options: {expanded?: false, includeUnknown?: boolean, length?: number}): Tags;
202
+ export function load(data: string | File): Promise<Tags>;
207
203
  export function load(data: string | File, options: {expanded: true, includeUnknown?: boolean, length?: number}): Promise<ExpandedTags>;
208
- export function load(data: string | File, options: {expanded?: false, includeUnknown?: boolean, length?: number}): Promise<Tags & XmpTags & IccTags>;
209
- export function loadView(data: DataView): Tags & XmpTags & IccTags;
204
+ export function load(data: string | File, options: {expanded?: false, includeUnknown?: boolean, length?: number}): Promise<Tags>;
205
+ export function loadView(data: DataView): Tags;
210
206
  export function loadView(data: DataView, options: {expanded: true, includeUnknown?: boolean}): ExpandedTags;
211
- export function loadView(data: DataView, options: {expanded?: false, includeUnknown?: boolean}): Tags & XmpTags & IccTags;
207
+ export function loadView(data: DataView, options: {expanded?: false, includeUnknown?: boolean}): Tags;
212
208
 
213
209
  export namespace errors {
214
210
  export class MetadataMissingError extends Error {}
215
211
  }
216
212
 
217
- interface Tags {
213
+ interface ExifTags {
218
214
  // Interoperability tags
219
215
  'InteroperabilityIndex'?: StringArrayTag,
220
216
 
@@ -364,7 +360,7 @@ interface Tags {
364
360
  'MPEntry'?: NumberArrayTag,
365
361
  'ImageUIDList'?: NumberArrayTag,
366
362
  'TotalFrames'?: NumberTag,
367
- 'Images'?: Array<MPFImageTags>,
363
+ 'Images'?: MPFImageTags[],
368
364
 
369
365
  // IPTC tags
370
366
  // IPTC tags don't have explicit types. Therefore the raw value will always
@@ -456,3 +452,10 @@ interface Tags {
456
452
  interface IccTags {
457
453
  [name: string]: ValueTag;
458
454
  }
455
+
456
+ export type Tags = XmpTags & IccTags & PngTags & {
457
+ 'Thumbnail'?: ThumbnailTags;
458
+ 'Images'?: MPFImageTags[],
459
+ } & {
460
+ [K in keyof ExifTags]: ExifTags[K] | XmpTag;
461
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "exifreader",
3
- "version": "4.11.0",
3
+ "version": "4.12.0",
4
4
  "description": "Library that parses Exif metadata in images.",
5
5
  "author": "Mattias Wallander <mattias@wallander.eu>",
6
6
  "repository": {
@@ -44,6 +44,7 @@
44
44
  "rimraf": "^3.0.2",
45
45
  "string-replace-loader": "^3.0.3",
46
46
  "terser-webpack-plugin": "^5.2.4",
47
+ "typescript": "^5.0.2",
47
48
  "webpack": "^5.74.0",
48
49
  "webpack-cli": "^4.10.0",
49
50
  "webpack-dev-server": "^4.11.1"
@@ -60,21 +61,22 @@
60
61
  "test:build:custom": "mocha --bail test/build/test-custom.js",
61
62
  "test:build:update": "node test/build/update.js",
62
63
  "test:e2e": "cypress run",
63
- "test:all": "npm-run-all lint coverage test:e2e test:build test:build:custom",
64
+ "test:types": "tsc --noEmit --project test/types",
65
+ "test:all": "npm-run-all lint coverage test:e2e test:build test:build:custom test:types",
64
66
  "postinstall": "node bin/build.js --only-with-config"
65
67
  },
66
68
  "nyc": {
67
69
  "check-coverage": true,
68
70
  "statements": 95,
69
- "branches": 93,
71
+ "branches": 92,
70
72
  "functions": 98,
71
- "lines": 96,
73
+ "lines": 95,
72
74
  "reporter": [
73
75
  "lcov",
74
76
  "text"
75
77
  ],
76
78
  "exclude": [
77
- "test/**/*.js",
79
+ "test/*",
78
80
  "**/node_modules/*"
79
81
  ]
80
82
  },