exifreader 4.23.5 → 4.23.7

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
@@ -232,7 +232,7 @@ const tags = ExifReader.load(fileBuffer, {expanded: true});
232
232
 
233
233
  If you're having trouble getting the GPS location, see [this comment and
234
234
  thread](https://github.com/mattiasw/ExifReader/issues/177#issuecomment-1172228225)
235
- for more details.
235
+ and the [GPS section below](#gps) for more details.
236
236
 
237
237
  #### Grouping
238
238
 
@@ -288,10 +288,11 @@ be negative for values that are south of the equator, west of the IRM, or below
288
288
  sealevel. These are often more convenient values for regular use. For some
289
289
  elaboration or if you need the original values, see [Notes](#notes) below.
290
290
 
291
- If you're having trouble getting the GPS values on Android and are using a
292
- `type="file"` input to upload the image, make sure you are not setting the
293
- `accept` attribute on the input element. Apparently setting the `accept` [will
294
- strip the GPS values](https://github.com/mattiasw/ExifReader/issues/378#issuecomment-2302705983).
291
+ If you're having trouble getting the GPS values on Android (and possibly also
292
+ IOS) and are using a `type="file"` input to upload the image, make sure you are
293
+ **not** setting `accept="image/*"` on the input element. Apparently
294
+ setting the `accept` attribute to this value [will strip the GPS
295
+ values](https://github.com/mattiasw/ExifReader/issues/378#issuecomment-2302705983).
295
296
 
296
297
  ### Using the thumbnail
297
298
 
@@ -351,10 +352,10 @@ not the source code. That means it's not possible to use the ES module (from the
351
352
  `src` folder) or any tree shaking to get the benefit of a custom build. Tree
352
353
  shaking will actually have close to no effect at all here so don't rely on it.
353
354
 
354
- This is for npm users that use the built file. To specify what functionality you
355
- want you can either use include pattern (start with an empty set and include) or
356
- exclude pattern (start with full functionality and exclude). If an include
357
- pattern is set, excludes will not be used.
355
+ This is for npm and yarn users that use the built file. To specify what
356
+ functionality you want you can either use include pattern (start with an empty
357
+ set and include) or exclude pattern (start with full functionality and exclude).
358
+ If an include pattern is set, excludes will not be used.
358
359
 
359
360
  For Exif and IPTC it's also possible to specify which tags you're interested in.
360
361
  Those tag groups have huge dictionaries of tags and you may not be interested in
@@ -412,6 +413,11 @@ npm rebuild exifreader
412
413
  ```
413
414
 
414
415
  With yarn 2+:
416
+
417
+ From my experience, you need a `node_modules` folder for the rebuild command to
418
+ work with yarn 2+. If you don't have it, run `yarn config set nodeLinker
419
+ node-modules` and then run `yarn`. Then you can try to rebuild:
420
+
415
421
  ```bash
416
422
  yarn rebuild exifreader
417
423
  ```
@@ -4,16 +4,16 @@
4
4
 
5
5
  const modules = {
6
6
  exif: [
7
- 'src/tag-names-0th-ifd.js',
8
- 'src/tag-names-exif-ifd.js',
9
- 'src/tag-names-gps-ifd.js',
10
- 'src/tag-names-interoperability-ifd.js'
7
+ 'src[/\\\\]tag-names-0th-ifd.js',
8
+ 'src[/\\\\]tag-names-exif-ifd.js',
9
+ 'src[/\\\\]tag-names-gps-ifd.js',
10
+ 'src[/\\\\]tag-names-interoperability-ifd.js'
11
11
  ],
12
12
  iptc: [
13
- 'src/iptc-tag-names.js'
13
+ 'src[/\\\\]iptc-tag-names.js'
14
14
  ],
15
15
  mpf: [
16
- 'src/tag-names-mpf-ifd.js'
16
+ 'src[/\\\\]tag-names-mpf-ifd.js'
17
17
  ]
18
18
  };
19
19
 
@@ -70,10 +70,14 @@ module.exports = function TagFilter() {
70
70
  function getFileModuleType(filename) {
71
71
  for (const module in modules) {
72
72
  for (const file of modules[module]) {
73
- if (filename.endsWith(file)) {
73
+ if (endsWith(filename, file)) {
74
74
  return module;
75
75
  }
76
76
  }
77
77
  }
78
78
  return false;
79
79
  }
80
+
81
+ function endsWith(string, suffix) {
82
+ return new RegExp(`${suffix}$`).test(string);
83
+ }
package/bin/build.js CHANGED
@@ -7,28 +7,25 @@ const fs = require('fs');
7
7
  const {execSync} = require('child_process');
8
8
  const dependentHasExifReaderConfig = require('./findDependentConfig');
9
9
 
10
- const WEBPACK_VERSION = '5.89.0';
11
- const WEBPACK_CLI_VERSION = '5.1.4';
12
-
13
10
  const EXIFREADER_ROOT_DIR = path.join(__dirname, '..');
14
11
  process.chdir(EXIFREADER_ROOT_DIR);
15
12
 
16
13
  if (!process.argv.includes('--only-with-config') || checkConfig()) {
17
- execSync(`npx -p webpack-cli@${WEBPACK_CLI_VERSION} -p webpack@${WEBPACK_VERSION} webpack`, {stdio: 'inherit'});
14
+ execSync(`npx -p ${getPackage('webpack-cli')} -p ${getPackage('webpack')} webpack`, {stdio: 'inherit'});
18
15
  }
19
16
 
20
17
  function checkConfig() {
21
18
  if (dependentHasExifReaderConfig()) {
22
19
  console.log('Installing ExifReader custom build dependencies...'); // eslint-disable-line no-console
23
20
  const packages = [
24
- '@babel/core@7.23.2',
25
- '@babel/preset-env@7.23.2',
26
- '@babel/register@7.22.15',
27
- 'babel-loader@8.2.5',
28
- 'cross-env@7.0.3',
29
- 'string-replace-loader@3.1.0',
30
- 'terser-webpack-plugin@5.3.9'
31
- ];
21
+ '@babel/core',
22
+ '@babel/preset-env',
23
+ '@babel/register',
24
+ 'babel-loader',
25
+ 'cross-env',
26
+ 'string-replace-loader',
27
+ 'terser-webpack-plugin'
28
+ ].map((_package) => getPackage(_package));
32
29
  const tmpDir = path.join(EXIFREADER_ROOT_DIR, '__tmp');
33
30
  try {
34
31
  initTmpDir(tmpDir);
@@ -36,6 +33,7 @@ function checkConfig() {
36
33
  console.log('Done.'); // eslint-disable-line no-console
37
34
  } catch (error) {
38
35
  console.error('Could not install requirements for a custom build:', error); // eslint-disable-line no-console
36
+ process.exit(1);
39
37
  } finally {
40
38
  cleanUpTmpDir(tmpDir);
41
39
  }
@@ -44,6 +42,11 @@ function checkConfig() {
44
42
  return false;
45
43
  }
46
44
 
45
+ function getPackage(name) {
46
+ const version = require(path.join(EXIFREADER_ROOT_DIR, 'package.json')).devDependencies[name].replace(/^\^/, '');
47
+ return `${name}@${version}`;
48
+ }
49
+
47
50
  function initTmpDir(tmpDir) {
48
51
  const nodeModulesDir = path.join(EXIFREADER_ROOT_DIR, 'node_modules');
49
52
  fs.mkdirSync(tmpDir, {recursive: true});
package/exif-reader.d.ts CHANGED
@@ -293,8 +293,8 @@ interface ExifTags {
293
293
  'SamplesPerPixel'?: NumberTag,
294
294
  'RowsPerStrip'?: NumberTag,
295
295
  'StripByteCounts'?: NumberArrayTag,
296
- 'XResolution'?: NumberTag | NumberFileTag, // Also in JFIF tags.
297
- 'YResolution'?: NumberTag | NumberFileTag, // Also in JFIF tags.
296
+ 'XResolution'?: RationalTag | NumberFileTag, // Also in JFIF tags.
297
+ 'YResolution'?: RationalTag | NumberFileTag, // Also in JFIF tags.
298
298
  'PlanarConfiguration'?: NumberTag,
299
299
  'ResolutionUnit'?: NumberTag,
300
300
  'TransferFunction'?: NumberArrayTag,
@@ -321,30 +321,30 @@ interface ExifTags {
321
321
  'JFIF Thumbnail'?: JfifThumbnailTag,
322
322
 
323
323
  // Exif tags
324
- 'ExposureTime'?: NumberTag,
325
- 'FNumber'?: NumberTag,
324
+ 'ExposureTime'?: RationalTag,
325
+ 'FNumber'?: RationalTag,
326
326
  'ExposureProgram'?: NumberTag,
327
327
  'SpectralSensitivity'?: StringArrayTag,
328
- 'ISOSpeedRatings'?: NumberTag & NumberArrayTag,
329
- 'OECF'?: NumberTag & NumberArrayTag,
328
+ 'ISOSpeedRatings'?: NumberTag | NumberArrayTag,
329
+ 'OECF'?: unknown,
330
330
  'ExifVersion'?: NumberArrayTag,
331
331
  'DateTimeOriginal'?: StringArrayTag,
332
332
  'DateTimeDigitized'?: StringArrayTag,
333
333
  'ComponentsConfiguration'?: NumberArrayTag,
334
- 'CompressedBitsPerPixel'?: NumberTag,
335
- 'ShutterSpeedValue'?: NumberTag,
336
- 'ApertureValue'?: NumberTag,
337
- 'BrightnessValue'?: NumberTag,
338
- 'ExposureBiasValue'?: NumberTag,
339
- 'MaxApertureValue'?: NumberTag,
340
- 'SubjectDistance'?: NumberTag,
334
+ 'CompressedBitsPerPixel'?: RationalTag,
335
+ 'ShutterSpeedValue'?: RationalTag,
336
+ 'ApertureValue'?: RationalTag,
337
+ 'BrightnessValue'?: RationalTag,
338
+ 'ExposureBiasValue'?: RationalTag,
339
+ 'MaxApertureValue'?: RationalTag,
340
+ 'SubjectDistance'?: RationalTag,
341
341
  'MeteringMode'?: NumberTag,
342
342
  'LightSource'?: NumberTag,
343
343
  'Flash'?: NumberTag,
344
- 'FocalLength'?: NumberTag,
344
+ 'FocalLength'?: RationalTag,
345
345
  'SubjectArea'?: NumberArrayTag,
346
- 'MakerNote'?: NumberTag & NumberArrayTag,
347
- 'UserComment'?: NumberTag & NumberArrayTag,
346
+ 'MakerNote'?: unknown,
347
+ 'UserComment'?: unknown,
348
348
  'SubSecTime'?: StringArrayTag,
349
349
  'SubSecTimeOriginal'?: StringArrayTag,
350
350
  'SubSecTimeDigitized'?: StringArrayTag,
@@ -355,27 +355,27 @@ interface ExifTags {
355
355
  'RelatedSoundFile'?: StringArrayTag,
356
356
  'Interoperability IFD Pointer'?: NumberTag,
357
357
  'FlashEnergy'?: NumberTag,
358
- 'SpatialFrequencyResponse'?: NumberTag & NumberArrayTag,
359
- 'FocalPlaneXResolution'?: NumberTag,
360
- 'FocalPlaneYResolution'?: NumberTag,
358
+ 'SpatialFrequencyResponse'?: unknown,
359
+ 'FocalPlaneXResolution'?: RationalTag,
360
+ 'FocalPlaneYResolution'?: RationalTag,
361
361
  'FocalPlaneResolutionUnit'?: NumberTag,
362
362
  'SubjectLocation'?: NumberArrayTag,
363
- 'ExposureIndex'?: NumberTag,
363
+ 'ExposureIndex'?: RationalTag,
364
364
  'SensingMethod'?: NumberTag,
365
365
  'FileSource'?: NumberTag,
366
366
  'SceneType'?: NumberTag,
367
- 'CFAPattern'?: NumberTag & NumberArrayTag,
367
+ 'CFAPattern'?: unknown,
368
368
  'CustomRendered'?: NumberTag,
369
369
  'ExposureMode'?: NumberTag,
370
370
  'WhiteBalance'?: NumberTag,
371
- 'DigitalZoomRatio'?: NumberTag,
371
+ 'DigitalZoomRatio'?: RationalTag,
372
372
  'FocalLengthIn35mmFilm'?: NumberTag,
373
373
  'SceneCaptureType'?: NumberTag,
374
374
  'GainControl'?: NumberTag,
375
375
  'Contrast'?: NumberTag,
376
376
  'Saturation'?: NumberTag,
377
377
  'Sharpness'?: NumberTag,
378
- 'DeviceSettingDescription'?: NumberTag & NumberArrayTag,
378
+ 'DeviceSettingDescription'?: unknown,
379
379
  'SubjectDistanceRange'?: NumberTag,
380
380
  'ImageUniqueID'?: StringArrayTag,
381
381
  'LensMake'?: StringArrayTag,
@@ -413,8 +413,8 @@ interface ExifTags {
413
413
  'GPSDestBearing'?: NumberTag,
414
414
  'GPSDestDistanceRef'?: StringArrayTag,
415
415
  'GPSDestDistance'?: NumberTag,
416
- 'GPSProcessingMethod'?: NumberTag & NumberArrayTag,
417
- 'GPSAreaInformation'?: NumberTag & NumberArrayTag,
416
+ 'GPSProcessingMethod'?: unknown,
417
+ 'GPSAreaInformation'?: unknown,
418
418
  'GPSDateStamp'?: StringArrayTag,
419
419
  'GPSDifferential'?: NumberTag,
420
420
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "exifreader",
3
- "version": "4.23.5",
3
+ "version": "4.23.7",
4
4
  "description": "Library that parses Exif metadata in images.",
5
5
  "author": "Mattias Wallander <mattias@wallander.eu>",
6
6
  "repository": {
@@ -25,11 +25,11 @@
25
25
  "@xmldom/xmldom": "^0.8.10"
26
26
  },
27
27
  "devDependencies": {
28
- "@babel/core": "^7.23.2",
29
- "@babel/preset-env": "^7.23.2",
30
- "@babel/register": "^7.22.15",
31
- "@types/node": "^18.11.9",
32
- "babel-loader": "^9.1.3",
28
+ "@babel/core": "^7.25.2",
29
+ "@babel/preset-env": "^7.25.4",
30
+ "@babel/register": "^7.24.6",
31
+ "@types/node": "^20.16.10",
32
+ "babel-loader": "^9.2.1",
33
33
  "babel-plugin-rewire": "^1.2.0",
34
34
  "chai": "^4.3.10",
35
35
  "cross-env": "^7.0.3",
@@ -42,8 +42,8 @@
42
42
  "nyc": "^17.0.0",
43
43
  "rimraf": "^5.0.5",
44
44
  "string-replace-loader": "^3.1.0",
45
- "terser-webpack-plugin": "^5.3.9",
46
- "typescript": "^5.2.2",
45
+ "terser-webpack-plugin": "^5.3.10",
46
+ "typescript": "^5.6.2",
47
47
  "webpack": "^5.89.0",
48
48
  "webpack-cli": "^5.1.4",
49
49
  "webpack-dev-server": "^5.0.4"
package/webpack.config.js CHANGED
@@ -81,7 +81,7 @@ module.exports = {
81
81
  }
82
82
  },
83
83
  {
84
- test: /\/(exif-reader|image-header-?(tiff|jpeg|png|heic|avif|iso-bmff|webp|gif)?|tags|tag-names)\.js$/,
84
+ test: /[/\\](exif-reader|image-header-?(tiff|jpeg|png|heic|avif|iso-bmff|webp|gif)?|tags|tag-names)\.js$/,
85
85
  loader: 'string-replace-loader',
86
86
  options: {
87
87
  multiple: getConstantReplacements(includedModules)