|
1 |
| -// High level API. |
2 |
| -import * as platform from './util/platform.mjs' |
3 |
| -import {Buffer} from './util/platform.mjs' |
4 |
| -import {Exifr} from './Exifr.mjs' |
5 |
| -import {TAG_GPS_LATREF, TAG_GPS_LAT, TAG_GPS_LONREF, TAG_GPS_LON, TAG_ORIENTATION} from './tags.mjs' |
| 1 | +import {Exifr} from '../Exifr.mjs' |
| 2 | +import {TAG_ORIENTATION} from '../tags.mjs' |
| 3 | +import {disableAllOptions} from './disableAllOptions.mjs' |
6 | 4 |
|
7 | 5 |
|
8 |
| -export const disableAllOptions = { |
9 |
| - ifd0: false, |
10 |
| - ifd1: false, |
11 |
| - exif: false, |
12 |
| - gps: false, |
13 |
| - interop: false, |
14 |
| - // turning off all unnecessary steps and transformation to get the needed data ASAP |
15 |
| - sanitize: false, |
16 |
| - reviveValues: true, |
17 |
| - translateKeys: false, |
18 |
| - translateValues: false, |
19 |
| - mergeOutput: false, |
20 |
| -} |
21 |
| - |
22 |
| -export const gpsOnlyOptions = Object.assign({}, disableAllOptions, { |
23 |
| - firstChunkSize: 40000, |
24 |
| - gps: [TAG_GPS_LATREF, TAG_GPS_LAT, TAG_GPS_LONREF, TAG_GPS_LON], |
25 |
| -}) |
26 |
| - |
27 | 6 | export const orientationOnlyOptions = Object.assign({}, disableAllOptions, {
|
28 | 7 | firstChunkSize: 40000,
|
29 | 8 | ifd0: [TAG_ORIENTATION],
|
30 | 9 | })
|
31 | 10 |
|
32 |
| -export const thumbnailOnlyOptions = Object.assign({}, disableAllOptions, { |
33 |
| - tiff: false, |
34 |
| - ifd1: true, |
35 |
| - // needed to prevent options from disabling ifd1 |
36 |
| - mergeOutput: false |
37 |
| -}) |
38 |
| - |
39 |
| - |
40 |
| -export async function thumbnail(input) { |
41 |
| - let exr = new Exifr(thumbnailOnlyOptions) |
42 |
| - await exr.read(input) |
43 |
| - let u8arr = await exr.extractThumbnail() |
44 |
| - if (u8arr && platform.hasBuffer) |
45 |
| - return Buffer.from(u8arr) |
46 |
| - else |
47 |
| - return u8arr |
48 |
| -} |
49 |
| - |
50 |
| -// only available in browser |
51 |
| -export async function thumbnailUrl(input) { |
52 |
| - let u8arr = await this.thumbnail(input) |
53 |
| - if (u8arr !== undefined) { |
54 |
| - let blob = new Blob([u8arr]) // note: dont use AB directly, because of byteOffset |
55 |
| - return URL.createObjectURL(blob) |
56 |
| - } |
57 |
| -} |
58 |
| - |
59 |
| -export async function gps(input) { |
60 |
| - let exr = new Exifr(gpsOnlyOptions) |
61 |
| - await exr.read(input) |
62 |
| - let output = await exr.parse() |
63 |
| - if (output && output.gps) { |
64 |
| - let {latitude, longitude} = output.gps |
65 |
| - return {latitude, longitude} |
66 |
| - } |
67 |
| -} |
68 |
| - |
69 | 11 | export async function orientation(input) {
|
70 | 12 | let exr = new Exifr(orientationOnlyOptions)
|
71 | 13 | await exr.read(input)
|
|
0 commit comments