@kitschpatrol/aphex 0.1.5 → 0.2.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/dist/aphex-swift +0 -0
- package/dist/assets/applescript-gui.applescript +293 -179
- package/dist/index.d.ts +351 -51
- package/dist/index.js +559 -176
- package/package.json +27 -23
- package/readme.md +92 -19
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
import { ExifTool } from "exiftool-vendored";
|
|
2
|
-
import { ILogBasic, ILogLayer } from "lognow";
|
|
3
1
|
import { OmitDeep, PartialDeep, Simplify } from "type-fest";
|
|
4
|
-
|
|
2
|
+
import "exiftool-vendored";
|
|
3
|
+
import { ILogBasic, ILogLayer } from "lognow";
|
|
5
4
|
/**
|
|
6
5
|
* Start an interactive session with aphex-swift. Commands will be sent to this
|
|
7
6
|
* persistent process instead of spawning new ones.
|
|
8
7
|
*
|
|
8
|
+
* If the process ends on its own after it has answered a command, or to get rid
|
|
9
|
+
* of a render that timed out, another one takes its place and carries on with
|
|
10
|
+
* the commands that were waiting.
|
|
11
|
+
*
|
|
9
12
|
* @throws {Error} If the session is already active or fails to start
|
|
10
13
|
*/
|
|
11
14
|
export declare function interactiveSessionStart(): Promise<void>;
|
|
@@ -14,62 +17,204 @@ export declare function interactiveSessionStart(): Promise<void>;
|
|
|
14
17
|
*/
|
|
15
18
|
export declare function interactiveSessionStop(): Promise<void>;
|
|
16
19
|
/**
|
|
17
|
-
*
|
|
20
|
+
* One of the image files Photos.app keeps for a photo, as reported by
|
|
21
|
+
* aphex-swift.
|
|
18
22
|
*/
|
|
19
23
|
type ResourceInfo = {
|
|
24
|
+
/**
|
|
25
|
+
* Uniform type identifier, like `public.jpeg`.
|
|
26
|
+
*/
|
|
20
27
|
contentType: string;
|
|
28
|
+
/**
|
|
29
|
+
* The name the file had when it was imported. Edited files are always called
|
|
30
|
+
* something like `FullSizeRender.jpg`.
|
|
31
|
+
*/
|
|
21
32
|
fileName: string;
|
|
33
|
+
/**
|
|
34
|
+
* Absolute path of the file inside the Photos.app library.
|
|
35
|
+
*/
|
|
22
36
|
filePath: string;
|
|
37
|
+
/**
|
|
38
|
+
* In bytes.
|
|
39
|
+
*/
|
|
23
40
|
fileSize: number;
|
|
41
|
+
/**
|
|
42
|
+
* In pixels.
|
|
43
|
+
*/
|
|
24
44
|
height: number;
|
|
45
|
+
/**
|
|
46
|
+
* In pixels.
|
|
47
|
+
*/
|
|
25
48
|
width: number;
|
|
26
49
|
};
|
|
27
50
|
/**
|
|
28
|
-
*
|
|
29
|
-
* iOS Photos framework (CodablePHAsset)
|
|
51
|
+
* A photo in the Photos.app library, as reported by aphex-swift.
|
|
30
52
|
*/
|
|
31
53
|
type PhotoInfo = {
|
|
54
|
+
/**
|
|
55
|
+
* When the photo was taken.
|
|
56
|
+
*/
|
|
32
57
|
dateCreated: Date;
|
|
58
|
+
/**
|
|
59
|
+
* The most recent modification time of the photo's files in the library, not
|
|
60
|
+
* the modification date Photos.app shows.
|
|
61
|
+
*/
|
|
33
62
|
dateModified: Date;
|
|
63
|
+
/**
|
|
64
|
+
* The edited image Photos.app stored when the photo was last edited, a
|
|
65
|
+
* compressed JPEG or HEIC. Only present if the photo has edits.
|
|
66
|
+
*/
|
|
34
67
|
edited?: ResourceInfo;
|
|
35
68
|
favorite: boolean;
|
|
36
69
|
hidden: boolean;
|
|
70
|
+
/**
|
|
71
|
+
* The image as it was imported.
|
|
72
|
+
*/
|
|
37
73
|
original: ResourceInfo;
|
|
74
|
+
/**
|
|
75
|
+
* Only present if a title has been set in Photos.app.
|
|
76
|
+
*/
|
|
38
77
|
title?: string;
|
|
78
|
+
/**
|
|
79
|
+
* The photo's local identifier. It is unique to this copy of the library, so
|
|
80
|
+
* the same photo has a different one on another Mac.
|
|
81
|
+
*/
|
|
39
82
|
uuid: string;
|
|
40
83
|
};
|
|
84
|
+
/**
|
|
85
|
+
* An album in the Photos.app library, as reported by aphex-swift.
|
|
86
|
+
*/
|
|
41
87
|
type AlbumInfo = {
|
|
88
|
+
/**
|
|
89
|
+
* When the newest photo in the album was taken, if Photos.app knows.
|
|
90
|
+
*/
|
|
42
91
|
dateEnd?: Date;
|
|
92
|
+
/**
|
|
93
|
+
* When the oldest photo in the album was taken, if Photos.app knows.
|
|
94
|
+
*/
|
|
43
95
|
dateStart?: Date;
|
|
96
|
+
/**
|
|
97
|
+
* PhotoKit's estimate, which is not guaranteed to be exact.
|
|
98
|
+
*/
|
|
44
99
|
estimatedAssetCount: number;
|
|
100
|
+
/**
|
|
101
|
+
* The album's place in the folder hierarchy, like `/Folder/Album`.
|
|
102
|
+
*/
|
|
45
103
|
path: string;
|
|
104
|
+
/**
|
|
105
|
+
* Raw value of PhotoKit's `PHAssetCollectionSubtype`.
|
|
106
|
+
*/
|
|
46
107
|
subtype: number;
|
|
47
108
|
title: string;
|
|
109
|
+
/**
|
|
110
|
+
* Raw value of PhotoKit's `PHAssetCollectionType`.
|
|
111
|
+
*/
|
|
48
112
|
type: number;
|
|
113
|
+
/**
|
|
114
|
+
* The album's local identifier, unique to this copy of the library.
|
|
115
|
+
*/
|
|
49
116
|
uuid: string;
|
|
50
117
|
};
|
|
51
118
|
/**
|
|
52
|
-
*
|
|
53
|
-
* or photo path)
|
|
119
|
+
* Look up photos in the Photos.app library.
|
|
54
120
|
*
|
|
55
|
-
* @
|
|
121
|
+
* @param identifiers Photo UUIDs, paths like `Album/Title` or
|
|
122
|
+
* `Album/IMG_1234.jpeg`, or album UUIDs and paths, which stand for every
|
|
123
|
+
* photo in the album.
|
|
124
|
+
* @param caseSensitive Whether titles, file names, and album paths have to
|
|
125
|
+
* match exactly.
|
|
126
|
+
*
|
|
127
|
+
* @returns One entry per photo found. Empty if no identifiers are passed.
|
|
128
|
+
* @throws {Error} If nothing matches, or the command fails.
|
|
56
129
|
*/
|
|
57
130
|
declare function aphexPhotoInfo(identifiers: string | string[], caseSensitive?: boolean): Promise<PhotoInfo[]>;
|
|
58
131
|
/**
|
|
59
|
-
*
|
|
132
|
+
* Look up albums in the Photos.app library.
|
|
133
|
+
*
|
|
134
|
+
* @param identifiers Album UUIDs, or paths like `Album` or `Folder/Album`.
|
|
135
|
+
* @param caseSensitive Whether album paths have to match exactly.
|
|
60
136
|
*
|
|
61
|
-
* @
|
|
137
|
+
* @returns One entry per album found. Empty if no identifiers are passed.
|
|
138
|
+
* @throws {Error} If nothing matches, or the command fails.
|
|
62
139
|
*/
|
|
63
140
|
declare function aphexAlbumInfo(identifiers: string | string[], caseSensitive?: boolean): Promise<AlbumInfo[]>;
|
|
64
|
-
|
|
65
|
-
|
|
141
|
+
/**
|
|
142
|
+
* Options for re-rendering a photo with its edits at full quality, the way File
|
|
143
|
+
* → Export does in Photos.app. Mirrors the `aphex export --format` flags.
|
|
144
|
+
*/
|
|
145
|
+
type AphexRenderOptions = {
|
|
146
|
+
/**
|
|
147
|
+
* Flatten the transparency of photos that have any onto this sRGB color
|
|
148
|
+
* instead of white, as six hexadecimal digits like `ff8800`. Can't be
|
|
149
|
+
* combined with `preserveAlpha`.
|
|
150
|
+
*/
|
|
151
|
+
background?: string;
|
|
152
|
+
/**
|
|
153
|
+
* Bits per channel. Only applies to `tiff`.
|
|
154
|
+
*/
|
|
155
|
+
bitDepth?: 8 | 16;
|
|
156
|
+
/**
|
|
157
|
+
* `original` keeps the color space the edit renders in. `most-compatible` is
|
|
158
|
+
* Display P3 tagged with Apple's backwards compatible sharing profile.
|
|
159
|
+
*/
|
|
160
|
+
colorProfile?: 'adobe-rgb' | 'display-p3' | 'most-compatible' | 'original' | 'srgb';
|
|
161
|
+
/**
|
|
162
|
+
* File format to render to. PNG and TIFF are lossless.
|
|
163
|
+
*/
|
|
164
|
+
format: 'heic' | 'jpeg' | 'png' | 'tiff';
|
|
165
|
+
/**
|
|
166
|
+
* Keep location metadata in the file.
|
|
167
|
+
*/
|
|
168
|
+
includeLocation?: boolean;
|
|
169
|
+
/**
|
|
170
|
+
* Write the title, caption, and keywords from the library into the file.
|
|
171
|
+
*/
|
|
172
|
+
includeMetadata?: boolean;
|
|
173
|
+
/**
|
|
174
|
+
* Scale down to fit this height in pixels. Never scales up.
|
|
175
|
+
*/
|
|
176
|
+
maxHeight?: number;
|
|
177
|
+
/**
|
|
178
|
+
* Scale down to fit this width in pixels. Never scales up.
|
|
179
|
+
*/
|
|
180
|
+
maxWidth?: number;
|
|
181
|
+
/**
|
|
182
|
+
* Keep the transparency of photos that have any, where Photos.app flattens it
|
|
183
|
+
* onto white. Only applies to `png` and `tiff`.
|
|
184
|
+
*/
|
|
185
|
+
preserveAlpha?: boolean;
|
|
186
|
+
/**
|
|
187
|
+
* JPEG quality from 0 to 1. Only applies to `jpeg`.
|
|
188
|
+
*/
|
|
189
|
+
quality?: number;
|
|
190
|
+
};
|
|
66
191
|
export declare const IMAGE_MIME_TYPES: readonly ["arw", "avif", "bmp", "cr2", "cr3", "crw", "tga", "dng", "gif", "heic", "heif", "jpeg", "nef", "pef", "png", "psd", "svg+xml", "tiff", "webp"];
|
|
67
192
|
type ImageMimeType = (typeof IMAGE_MIME_TYPES)[number];
|
|
68
|
-
//#endregion
|
|
69
|
-
//#region src/pipeline/engines/applescript-gui.d.ts
|
|
70
193
|
/**
|
|
71
|
-
*
|
|
72
|
-
*
|
|
194
|
+
* Options for the `swift-render` engine. These cover the same ground as the
|
|
195
|
+
* Photos.app export sheet, see `ExportViaAppleScriptGuiOptions`.
|
|
196
|
+
*/
|
|
197
|
+
type ExportViaSwiftRenderOptions = Required<Omit<AphexRenderOptions, 'background' | 'maxHeight' | 'maxWidth'>> & {
|
|
198
|
+
/**
|
|
199
|
+
* Flatten the transparency of photos that have any onto this sRGB color, as
|
|
200
|
+
* six hexadecimal digits like `ff8800`. `undefined` flattens onto white, like
|
|
201
|
+
* Photos.app, unless `preserveAlpha` is set.
|
|
202
|
+
*/
|
|
203
|
+
background: string | undefined;
|
|
204
|
+
/**
|
|
205
|
+
* Scale down to fit this height in pixels. `undefined` leaves the height
|
|
206
|
+
* unconstrained.
|
|
207
|
+
*/
|
|
208
|
+
maxHeight: number | undefined;
|
|
209
|
+
/**
|
|
210
|
+
* Scale down to fit this width in pixels. `undefined` leaves the width
|
|
211
|
+
* unconstrained.
|
|
212
|
+
*/
|
|
213
|
+
maxWidth: number | undefined;
|
|
214
|
+
};
|
|
215
|
+
/**
|
|
216
|
+
* Mirrors the export sheet in Photos.app. Note that some options are contingent
|
|
217
|
+
* on others.
|
|
73
218
|
*
|
|
74
219
|
* The AppleScript implementation is smart about only "clicking" the necessary
|
|
75
220
|
* options in the GUI.
|
|
@@ -120,43 +265,116 @@ type ExportViaAppleScriptGuiOptions = {
|
|
|
120
265
|
*/
|
|
121
266
|
tiffBitDepth: 8 | 16;
|
|
122
267
|
};
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
268
|
+
/**
|
|
269
|
+
* A way of getting an image file out of the Photos.app library.
|
|
270
|
+
*
|
|
271
|
+
* - `swift-render` renders the original image and its edits again, with the
|
|
272
|
+
* private frameworks Photos.app uses. Same result as File → Export.
|
|
273
|
+
* - `photos-gui` drives the Photos.app export sheet through AppleScript GUI
|
|
274
|
+
* automation. Same result, but slow, and it takes over the screen.
|
|
275
|
+
* - `swift-photokit` asks PhotoKit for the image stored in the library: the
|
|
276
|
+
* untouched original, or for an edited photo, a compressed JPEG or HEIC.
|
|
277
|
+
* - `file-system` copies that same stored image straight out of the library
|
|
278
|
+
* folder.
|
|
279
|
+
* - `applescript` uses the `export` command of the Photos.app AppleScript
|
|
280
|
+
* dictionary, which gives a JPEG.
|
|
281
|
+
*/
|
|
282
|
+
type ExportEngine = 'applescript' | 'file-system' | 'photos-gui' | 'swift-photokit' | 'swift-render';
|
|
283
|
+
/**
|
|
284
|
+
* Either one engine for every photo, or a map from image format to engine. With
|
|
285
|
+
* a map, a photo in a format that has no entry fails to export.
|
|
286
|
+
*/
|
|
126
287
|
type ExportEngineOptions = ExportEngine | Partial<Record<ImageMimeType, ExportEngine>>;
|
|
127
288
|
type ExportApplePhotoOptions = {
|
|
289
|
+
/**
|
|
290
|
+
* Options for the `photos-gui` engine, named after the controls of the
|
|
291
|
+
* Photos.app export sheet.
|
|
292
|
+
*/
|
|
128
293
|
appleScriptGuiOptions: ExportViaAppleScriptGuiOptions;
|
|
294
|
+
/**
|
|
295
|
+
* Engine for photos that have been edited in Photos.app. A map is keyed by
|
|
296
|
+
* the format of the edited image stored in the library.
|
|
297
|
+
*/
|
|
129
298
|
engineEdited: ExportEngineOptions;
|
|
299
|
+
/**
|
|
300
|
+
* Engine for edited photos whose original has transparency.
|
|
301
|
+
*/
|
|
130
302
|
engineEditedAlpha: ExportEngineOptions;
|
|
303
|
+
/**
|
|
304
|
+
* Engine for photos without edits. A map is keyed by the format of the
|
|
305
|
+
* original.
|
|
306
|
+
*/
|
|
131
307
|
engineOriginal: ExportEngineOptions;
|
|
308
|
+
/**
|
|
309
|
+
* Engine for photos without edits that have transparency.
|
|
310
|
+
*/
|
|
132
311
|
engineOriginalAlpha: ExportEngineOptions;
|
|
133
312
|
/**
|
|
134
|
-
* Append
|
|
135
|
-
*
|
|
136
|
-
*
|
|
137
|
-
* content hash.
|
|
313
|
+
* Append the last eight characters of the photo's UUID to file names taken
|
|
314
|
+
* from its title or original file name, to keep photos that share a name
|
|
315
|
+
* apart. Turned on automatically when two photos in one export would collide.
|
|
316
|
+
* This is NOT the same as a content hash.
|
|
138
317
|
*/
|
|
139
318
|
fileNameAppendUuidFragment: boolean;
|
|
319
|
+
/**
|
|
320
|
+
* Lowercase file extensions, and spell them `.jpeg` and `.tiff`.
|
|
321
|
+
*/
|
|
140
322
|
fileNameNormalizeExtensions: boolean;
|
|
323
|
+
/**
|
|
324
|
+
* What to name exported files after, in order of preference: the photo's
|
|
325
|
+
* `title`, the original `fileName` without its extension, or the `uuid`. The
|
|
326
|
+
* first one the photo has is used.
|
|
327
|
+
*/
|
|
141
328
|
fileNamePrecedence: FileNameOptions[];
|
|
329
|
+
/**
|
|
330
|
+
* Turn file names into lowercase, URL-friendly slugs.
|
|
331
|
+
*/
|
|
142
332
|
fileNameSluggify: boolean;
|
|
333
|
+
/**
|
|
334
|
+
* Options for the `swift-render` engine, which re-renders photos and their
|
|
335
|
+
* edits at full quality without automating the Photos.app GUI.
|
|
336
|
+
*/
|
|
337
|
+
swiftRenderOptions: ExportViaSwiftRenderOptions;
|
|
143
338
|
};
|
|
144
339
|
type ExportApplePhotoResult = {
|
|
340
|
+
/**
|
|
341
|
+
* Whether the file falls short of what the options asked for. That happens
|
|
342
|
+
* when a render fails and the Photos.app GUI, which takes over, can't do the
|
|
343
|
+
* same: it flattens transparency onto white, and has fewer choices of JPEG
|
|
344
|
+
* quality and size. A sync exports such a photo again the next time.
|
|
345
|
+
*/
|
|
346
|
+
exportDegraded: boolean;
|
|
347
|
+
/**
|
|
348
|
+
* The engine that produced the file. Differs from the configured one if that
|
|
349
|
+
* failed and another took over.
|
|
350
|
+
*/
|
|
145
351
|
exportEngine: ExportEngine;
|
|
146
352
|
exportOptions: ExportApplePhotoOptions;
|
|
147
353
|
path: string;
|
|
148
354
|
photoInfo: PhotoInfo;
|
|
149
355
|
};
|
|
150
356
|
type FileNameOptions = 'fileName' | 'title' | 'uuid';
|
|
151
|
-
//#endregion
|
|
152
|
-
//#region src/utilities/image/tags.d.ts
|
|
153
357
|
declare const VALID_LABELS: readonly ["animation", "diagram", "illustration", "image", "photo", "render", "screenshot", "video"];
|
|
154
358
|
type Label = (typeof VALID_LABELS)[number];
|
|
155
359
|
type ValidateTagsResult = {
|
|
156
360
|
issues: string[];
|
|
157
361
|
valid: boolean;
|
|
158
362
|
};
|
|
363
|
+
/**
|
|
364
|
+
* What Aphex records in an exported file, so that a later sync can tell whether
|
|
365
|
+
* the file is still up to date
|
|
366
|
+
*/
|
|
159
367
|
type AphexMetadata = {
|
|
368
|
+
/**
|
|
369
|
+
* Set when the file falls short of the options, see `ExportApplePhotoResult`.
|
|
370
|
+
* Absent in files from older versions of Aphex.
|
|
371
|
+
*/
|
|
372
|
+
exportDegraded?: boolean;
|
|
373
|
+
/**
|
|
374
|
+
* The engine that produced the file, which is not always the one the options
|
|
375
|
+
* name. Absent in files from older versions of Aphex.
|
|
376
|
+
*/
|
|
377
|
+
exportEngine?: ExportEngine;
|
|
160
378
|
exportOptions: ExportOptions;
|
|
161
379
|
photoInfo: PhotoInfo;
|
|
162
380
|
};
|
|
@@ -175,13 +393,30 @@ type ImageTags = {
|
|
|
175
393
|
label?: Label | undefined;
|
|
176
394
|
preservedFileName?: string | undefined;
|
|
177
395
|
};
|
|
178
|
-
//#endregion
|
|
179
|
-
//#region src/pipeline/image-metadata.d.ts
|
|
180
396
|
type ManageMetadataOptions = {
|
|
397
|
+
/**
|
|
398
|
+
* Copy `tagsToSync` from a photo's original file onto the edited image
|
|
399
|
+
* Photos.app stores for it. Note that this writes to a file inside the
|
|
400
|
+
* Photos.app library.
|
|
401
|
+
*/
|
|
181
402
|
syncToEdited: boolean;
|
|
403
|
+
/**
|
|
404
|
+
* Copy `tagsToSync` from a photo's original file to the exported file.
|
|
405
|
+
*/
|
|
182
406
|
syncToTarget: boolean;
|
|
407
|
+
/**
|
|
408
|
+
* The XMP tags to copy.
|
|
409
|
+
*/
|
|
183
410
|
tagsToSync: Array<keyof ImageTags>;
|
|
411
|
+
/**
|
|
412
|
+
* Check that the exported file has the expected tags, and log a warning for
|
|
413
|
+
* any that are missing.
|
|
414
|
+
*/
|
|
184
415
|
validate: boolean;
|
|
416
|
+
/**
|
|
417
|
+
* Record the photo's library information and the export options in the
|
|
418
|
+
* exported file. Sync relies on this to recognize files that are up to date.
|
|
419
|
+
*/
|
|
185
420
|
writeAphexMetadata: boolean;
|
|
186
421
|
};
|
|
187
422
|
type ManageMetadataResult = {
|
|
@@ -190,16 +425,12 @@ type ManageMetadataResult = {
|
|
|
190
425
|
tagsToTarget: Array<keyof ImageTags> | undefined;
|
|
191
426
|
validationResult: undefined | ValidateTagsResult;
|
|
192
427
|
};
|
|
193
|
-
//#endregion
|
|
194
|
-
//#region src/utilities/image/color.d.ts
|
|
195
428
|
declare const validColorProfiles: readonly ["Adobe RGB (1998)", "Apple Wide Color Sharing Profile", "Display P3", "None", "ProPhoto RGB", "sRGB IEC61966-2.1", "Unsupported"];
|
|
196
429
|
type ColorProfile = (typeof validColorProfiles)[number];
|
|
197
430
|
/**
|
|
198
431
|
* Normalize the color profile of an image
|
|
199
432
|
*/
|
|
200
433
|
declare function normalizeColorProfile(imagePath: string, preserveColorProfiles?: ColorProfile[], defaultColorProfile?: ColorProfile): Promise<'assigned' | 'converted' | 'no-action'>;
|
|
201
|
-
//#endregion
|
|
202
|
-
//#region src/utilities/image/convert.d.ts
|
|
203
434
|
type LosslessFormat = 'avif' | 'none' | 'png' | 'webp';
|
|
204
435
|
type NearLosslessFormat = 'none' | 'webp';
|
|
205
436
|
type LossyFormat = 'avif' | 'jpeg' | 'none' | 'webp';
|
|
@@ -269,8 +500,6 @@ declare function compressImage(sourceImagePath: string, destinationDirectory: st
|
|
|
269
500
|
compression: 'lossless' | 'lossy' | 'near-lossless' | 'none';
|
|
270
501
|
path: string;
|
|
271
502
|
}>;
|
|
272
|
-
//#endregion
|
|
273
|
-
//#region src/utilities/image/image.d.ts
|
|
274
503
|
type ImageInfo = {
|
|
275
504
|
alpha: boolean;
|
|
276
505
|
colorProfile: string;
|
|
@@ -283,8 +512,6 @@ type ImageInfo = {
|
|
|
283
512
|
sizeBytes: number;
|
|
284
513
|
tags: ImageTags;
|
|
285
514
|
};
|
|
286
|
-
//#endregion
|
|
287
|
-
//#region src/pipeline/image-process.d.ts
|
|
288
515
|
type ProcessImageOptions = CompressImageOptions & {
|
|
289
516
|
/** Fallback color profile applied when source profile is not in preserve list */
|
|
290
517
|
defaultColorProfile: ColorProfile;
|
|
@@ -328,13 +555,35 @@ type ProcessImageResult = {
|
|
|
328
555
|
* Run in parallel through a worker for album processing
|
|
329
556
|
*/
|
|
330
557
|
export declare function processImage(sourceImagePath: string, destinationDirectory: string, options: ProcessImageOptions): Promise<ProcessImageResult>;
|
|
331
|
-
//#endregion
|
|
332
|
-
//#region src/pipeline/image-sync.d.ts
|
|
333
558
|
type DiffStrategy = 'exif-tags' | 'export-options' | 'file-name' | 'force-update' | 'metadata-options' | 'photo-info' | 'process-options';
|
|
334
559
|
type SyncOptions = {
|
|
560
|
+
/**
|
|
561
|
+
* Delete every file in the destination directory that isn't the export of one
|
|
562
|
+
* of the photos being exported.
|
|
563
|
+
*/
|
|
335
564
|
deleteOthers: boolean;
|
|
565
|
+
/**
|
|
566
|
+
* Delete a photo's existing export when it is out of date, once it has been
|
|
567
|
+
* exported again. A new export of the same name replaces the old one either
|
|
568
|
+
* way.
|
|
569
|
+
*/
|
|
336
570
|
deleteTarget: boolean;
|
|
571
|
+
/**
|
|
572
|
+
* The checks that decide whether a photo's existing export is out of date,
|
|
573
|
+
* tried in order until one finds a difference:
|
|
574
|
+
*
|
|
575
|
+
* - `file-name`: the name the export would get has changed
|
|
576
|
+
* - `photo-info`: the photo changed in the library, for example by an edit
|
|
577
|
+
* - `export-options`, `process-options`, `metadata-options`: that group of
|
|
578
|
+
* options differs from the ones the export was made with. `export-options`
|
|
579
|
+
* also finds a difference if the export fell short of its options, because
|
|
580
|
+
* a render failed and the Photos.app GUI couldn't do the same.
|
|
581
|
+
* - `exif-tags`: the synced tags differ between the original and the export
|
|
582
|
+
*/
|
|
337
583
|
diffStrategies: DiffStrategy[];
|
|
584
|
+
/**
|
|
585
|
+
* Treat every existing export as out of date.
|
|
586
|
+
*/
|
|
338
587
|
forceUpdate: boolean;
|
|
339
588
|
};
|
|
340
589
|
type SyncResult = {
|
|
@@ -346,17 +595,14 @@ type SyncResult = {
|
|
|
346
595
|
}>;
|
|
347
596
|
toDelete: string[];
|
|
348
597
|
};
|
|
349
|
-
//#endregion
|
|
350
|
-
//#region src/utilities/exiftool.d.ts
|
|
351
598
|
/**
|
|
352
599
|
* End the exiftool process gracefully
|
|
353
600
|
*
|
|
354
601
|
* This should be called when you're done using exiftool to prevent hanging
|
|
355
|
-
* processes. It's safe to call multiple times
|
|
602
|
+
* processes. It's safe to call multiple times, and exiftool starts again the
|
|
603
|
+
* next time it's needed.
|
|
356
604
|
*/
|
|
357
605
|
export declare function endExiftool(): Promise<void>;
|
|
358
|
-
//#endregion
|
|
359
|
-
//#region src/utilities/log.d.ts
|
|
360
606
|
/**
|
|
361
607
|
* Set the logger instance for the module. Export this for library consumers to
|
|
362
608
|
* inject their own logger.
|
|
@@ -365,41 +611,95 @@ export declare function endExiftool(): Promise<void>;
|
|
|
365
611
|
* Stream-like log target
|
|
366
612
|
*/
|
|
367
613
|
export declare function setLogger(logger?: ILogBasic | ILogLayer<unknown>): void;
|
|
368
|
-
//#endregion
|
|
369
|
-
//#region src/index.d.ts
|
|
370
614
|
/**
|
|
371
|
-
*
|
|
372
|
-
* Exported for unplugin-aphex.
|
|
615
|
+
* Fill in everything a partial `ExportOptions` object leaves out with the
|
|
616
|
+
* library defaults. Exported for unplugin-aphex.
|
|
373
617
|
*/
|
|
374
618
|
export declare function mergeDefaultExportOptions(options: PartialDeep<ExportOptions> | undefined): ExportOptions;
|
|
619
|
+
/**
|
|
620
|
+
* Everything that controls an export, one group of options per stage. Every
|
|
621
|
+
* stage but the export itself can be skipped by passing `'disabled'`.
|
|
622
|
+
*/
|
|
375
623
|
export type ExportOptions = {
|
|
624
|
+
/**
|
|
625
|
+
* How photos are read out of the Photos.app library, and how the exported
|
|
626
|
+
* files are named.
|
|
627
|
+
*/
|
|
376
628
|
exportOptions: ExportApplePhotoOptions;
|
|
629
|
+
/**
|
|
630
|
+
* Which metadata is carried over to the exported files, and whether it is
|
|
631
|
+
* validated.
|
|
632
|
+
*/
|
|
377
633
|
metadataOptions: 'disabled' | ManageMetadataOptions;
|
|
634
|
+
/**
|
|
635
|
+
* Resizing, compression, and color profile normalization of the exported
|
|
636
|
+
* files.
|
|
637
|
+
*/
|
|
378
638
|
processOptions: 'disabled' | ProcessImageOptions;
|
|
639
|
+
/**
|
|
640
|
+
* Skipping photos whose exported file is already up to date, and deleting
|
|
641
|
+
* files that are out of date.
|
|
642
|
+
*/
|
|
379
643
|
syncOptions: 'disabled' | SyncOptions;
|
|
380
644
|
};
|
|
381
645
|
export declare const defaultSyncOptions: SyncOptions;
|
|
382
646
|
export declare const defaultExportOptions: ExportOptions;
|
|
383
|
-
/**
|
|
647
|
+
/**
|
|
648
|
+
* What each stage did for one photo. A stage that was disabled, or skipped
|
|
649
|
+
* because the photo was already up to date, is `undefined`. Fields that
|
|
650
|
+
* `ExportResult` already carries are left out.
|
|
651
|
+
*/
|
|
384
652
|
type ExportResults = {
|
|
385
653
|
exportResult: Simplify<Omit<ExportApplePhotoResult, 'exportOptions' | 'path' | 'photoInfo'>> | undefined;
|
|
386
654
|
metadataResult: Simplify<Omit<ManageMetadataResult, 'photoInfo'>> | undefined;
|
|
387
655
|
processResult: Simplify<OmitDeep<ProcessImageResult, 'input.path' | 'output.path' | 'path'>> | undefined;
|
|
388
656
|
syncResult: Simplify<Omit<SyncResult['plan'][number], 'photoInfo'>> | undefined;
|
|
389
657
|
};
|
|
658
|
+
/**
|
|
659
|
+
* The outcome of exporting one photo.
|
|
660
|
+
*/
|
|
390
661
|
export type ExportResult = {
|
|
662
|
+
/**
|
|
663
|
+
* The options the export ran with, defaults included.
|
|
664
|
+
*/
|
|
391
665
|
options: ExportOptions;
|
|
666
|
+
/**
|
|
667
|
+
* Where the exported file is. For a photo that was already up to date, this
|
|
668
|
+
* is the existing file.
|
|
669
|
+
*/
|
|
392
670
|
path: string;
|
|
393
671
|
photoInfo: PhotoInfo;
|
|
394
672
|
results: ExportResults;
|
|
395
673
|
};
|
|
396
674
|
/**
|
|
397
|
-
* Export a single photo
|
|
675
|
+
* Export a single photo from the Photos.app library to a directory.
|
|
676
|
+
*
|
|
677
|
+
* @param identifier A photo's UUID, a path like `Album/Title` or
|
|
678
|
+
* `Folder/Album/IMG_1234.jpeg`, or a `PhotoInfo` from `getPhotoInfo`.
|
|
679
|
+
* @param destinationDirectory Created if it doesn't exist. A leading `~` is
|
|
680
|
+
* expanded.
|
|
681
|
+
* @param options Anything left out falls back to the library defaults.
|
|
682
|
+
* @throws {Error} If the identifier matches no photo, or more than one.
|
|
398
683
|
*/
|
|
399
684
|
export declare function exportPhoto(identifier: PhotoInfo | string, destinationDirectory: string, options?: PartialDeep<ExportOptions>): Promise<ExportResult>;
|
|
400
685
|
/**
|
|
401
|
-
* Export photos
|
|
686
|
+
* Export any number of photos and albums from the Photos.app library to a
|
|
687
|
+
* directory.
|
|
688
|
+
*
|
|
689
|
+
* Each photo goes through the stages that are enabled in `options`: checking
|
|
690
|
+
* whether an up-to-date export already exists, exporting from Photos.app,
|
|
691
|
+
* processing, and writing metadata.
|
|
692
|
+
*
|
|
693
|
+
* @param identifiers Any mix of photo and album identifiers: UUIDs, paths like
|
|
694
|
+
* `Album/Title` or `Folder/Album`, and `PhotoInfo` or `AlbumInfo` objects. An
|
|
695
|
+
* album stands for every photo in it.
|
|
696
|
+
* @param destinationDirectory Created if it doesn't exist. A leading `~` is
|
|
697
|
+
* expanded.
|
|
698
|
+
* @param options Anything left out falls back to the library defaults.
|
|
699
|
+
*
|
|
700
|
+
* @returns One result per photo, in a flat list. A photo that is identified
|
|
701
|
+
* more than once is exported once.
|
|
702
|
+
* @throws {Error} If the identifiers match no photos.
|
|
402
703
|
*/
|
|
403
704
|
export declare function exportPhotos(identifiers: Array<AlbumInfo | PhotoInfo | string>, destinationDirectory: string, options?: PartialDeep<ExportOptions>): Promise<ExportResult[]>;
|
|
404
|
-
//#endregion
|
|
405
705
|
export { type ImageMimeType, aphexAlbumInfo as getAlbumInfo, aphexPhotoInfo as getPhotoInfo };
|