@kitschpatrol/aphex 0.2.0 → 0.3.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/index.d.ts +26 -41
- package/dist/index.js +38 -179
- package/package.json +2 -2
- package/readme.md +12 -13
package/dist/aphex-swift
CHANGED
|
Binary file
|
package/dist/index.d.ts
CHANGED
|
@@ -190,28 +190,6 @@ type AphexRenderOptions = {
|
|
|
190
190
|
};
|
|
191
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"];
|
|
192
192
|
type ImageMimeType = (typeof IMAGE_MIME_TYPES)[number];
|
|
193
|
-
/**
|
|
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
193
|
/**
|
|
216
194
|
* Mirrors the export sheet in Photos.app. Note that some options are contingent
|
|
217
195
|
* on others.
|
|
@@ -265,6 +243,28 @@ type ExportViaAppleScriptGuiOptions = {
|
|
|
265
243
|
*/
|
|
266
244
|
tiffBitDepth: 8 | 16;
|
|
267
245
|
};
|
|
246
|
+
/**
|
|
247
|
+
* Options for the `swift-render` engine. These cover the same ground as the
|
|
248
|
+
* Photos.app export sheet, see `ExportViaAppleScriptGuiOptions`.
|
|
249
|
+
*/
|
|
250
|
+
type ExportViaSwiftRenderOptions = Required<Omit<AphexRenderOptions, 'background' | 'maxHeight' | 'maxWidth'>> & {
|
|
251
|
+
/**
|
|
252
|
+
* Flatten the transparency of photos that have any onto this sRGB color, as
|
|
253
|
+
* six hexadecimal digits like `ff8800`. `undefined` flattens onto white, like
|
|
254
|
+
* Photos.app, unless `preserveAlpha` is set.
|
|
255
|
+
*/
|
|
256
|
+
background: string | undefined;
|
|
257
|
+
/**
|
|
258
|
+
* Scale down to fit this height in pixels. `undefined` leaves the height
|
|
259
|
+
* unconstrained.
|
|
260
|
+
*/
|
|
261
|
+
maxHeight: number | undefined;
|
|
262
|
+
/**
|
|
263
|
+
* Scale down to fit this width in pixels. `undefined` leaves the width
|
|
264
|
+
* unconstrained.
|
|
265
|
+
*/
|
|
266
|
+
maxWidth: number | undefined;
|
|
267
|
+
};
|
|
268
268
|
/**
|
|
269
269
|
* A way of getting an image file out of the Photos.app library.
|
|
270
270
|
*
|
|
@@ -338,15 +338,7 @@ type ExportApplePhotoOptions = {
|
|
|
338
338
|
};
|
|
339
339
|
type ExportApplePhotoResult = {
|
|
340
340
|
/**
|
|
341
|
-
*
|
|
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.
|
|
341
|
+
* The engine the options picked for the photo, which produced the file.
|
|
350
342
|
*/
|
|
351
343
|
exportEngine: ExportEngine;
|
|
352
344
|
exportOptions: ExportApplePhotoOptions;
|
|
@@ -366,13 +358,8 @@ type ValidateTagsResult = {
|
|
|
366
358
|
*/
|
|
367
359
|
type AphexMetadata = {
|
|
368
360
|
/**
|
|
369
|
-
*
|
|
370
|
-
*
|
|
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.
|
|
361
|
+
* The engine that produced the file. Absent in files from older versions of
|
|
362
|
+
* Aphex.
|
|
376
363
|
*/
|
|
377
364
|
exportEngine?: ExportEngine;
|
|
378
365
|
exportOptions: ExportOptions;
|
|
@@ -575,9 +562,7 @@ type SyncOptions = {
|
|
|
575
562
|
* - `file-name`: the name the export would get has changed
|
|
576
563
|
* - `photo-info`: the photo changed in the library, for example by an edit
|
|
577
564
|
* - `export-options`, `process-options`, `metadata-options`: that group of
|
|
578
|
-
* options differs from the ones the export was made with
|
|
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.
|
|
565
|
+
* options differs from the ones the export was made with
|
|
581
566
|
* - `exif-tags`: the synced tags differ between the original and the export
|
|
582
567
|
*/
|
|
583
568
|
diffStrategies: DiffStrategy[];
|
package/dist/index.js
CHANGED
|
@@ -1037,85 +1037,6 @@ const defaultExportViaAppleScriptGuiOptions = {
|
|
|
1037
1037
|
subfolderFormat: "None",
|
|
1038
1038
|
tiffBitDepth: 8
|
|
1039
1039
|
};
|
|
1040
|
-
const GUI_COLOR_PROFILES = {
|
|
1041
|
-
"adobe-rgb": "AdobeRGB",
|
|
1042
|
-
"display-p3": "Display P3",
|
|
1043
|
-
"most-compatible": "Most Compatible",
|
|
1044
|
-
original: "Original",
|
|
1045
|
-
srgb: "sRGB"
|
|
1046
|
-
};
|
|
1047
|
-
const GUI_PHOTO_KINDS = {
|
|
1048
|
-
heic: "HEIC",
|
|
1049
|
-
jpeg: "JPEG",
|
|
1050
|
-
png: "PNG",
|
|
1051
|
-
tiff: "TIFF"
|
|
1052
|
-
};
|
|
1053
|
-
const GUI_JPEG_QUALITIES = [
|
|
1054
|
-
{
|
|
1055
|
-
name: "Low (smallest Size)",
|
|
1056
|
-
quality: .25
|
|
1057
|
-
},
|
|
1058
|
-
{
|
|
1059
|
-
name: "Medium",
|
|
1060
|
-
quality: .5
|
|
1061
|
-
},
|
|
1062
|
-
{
|
|
1063
|
-
name: "High",
|
|
1064
|
-
quality: .75
|
|
1065
|
-
},
|
|
1066
|
-
{
|
|
1067
|
-
name: "Maximum",
|
|
1068
|
-
quality: 1
|
|
1069
|
-
}
|
|
1070
|
-
];
|
|
1071
|
-
/**
|
|
1072
|
-
* Work out the export sheet settings that come closest to a set of
|
|
1073
|
-
* `swift-render` options, for exporting through the GUI what couldn't be
|
|
1074
|
-
* rendered. The sheet drives the same renderer, so matching settings give the
|
|
1075
|
-
* same image.
|
|
1076
|
-
*
|
|
1077
|
-
* Transparency is not covered: the sheet always flattens it onto white,
|
|
1078
|
-
* whatever `preserveAlpha` and `background` say.
|
|
1079
|
-
*
|
|
1080
|
-
* @returns The settings, and whether they match the options exactly. They can't
|
|
1081
|
-
* for a JPEG quality between the sheet's four levels, or for a width and a
|
|
1082
|
-
* height limit that differ.
|
|
1083
|
-
*/
|
|
1084
|
-
function getAppleScriptGuiOptionsForRender(renderOptions) {
|
|
1085
|
-
const { bitDepth, colorProfile, format, includeLocation, includeMetadata, quality } = renderOptions;
|
|
1086
|
-
const maxWidth = renderOptions.maxWidth === void 0 ? void 0 : Math.floor(renderOptions.maxWidth);
|
|
1087
|
-
const maxHeight = renderOptions.maxHeight === void 0 ? void 0 : Math.floor(renderOptions.maxHeight);
|
|
1088
|
-
let exact = true;
|
|
1089
|
-
const options = {
|
|
1090
|
-
colorProfile: GUI_COLOR_PROFILES[colorProfile],
|
|
1091
|
-
includeLocation,
|
|
1092
|
-
includeMetadata,
|
|
1093
|
-
photoKind: GUI_PHOTO_KINDS[format],
|
|
1094
|
-
photoSize: "Full Size",
|
|
1095
|
-
tiffBitDepth: bitDepth
|
|
1096
|
-
};
|
|
1097
|
-
if (format === "jpeg") {
|
|
1098
|
-
let closest = GUI_JPEG_QUALITIES[0];
|
|
1099
|
-
for (const level of GUI_JPEG_QUALITIES) if (Math.abs(level.quality - quality) < Math.abs(closest.quality - quality)) closest = level;
|
|
1100
|
-
options.jpegQuality = closest.name;
|
|
1101
|
-
exact &&= closest.quality === quality;
|
|
1102
|
-
}
|
|
1103
|
-
if (maxWidth !== void 0 || maxHeight !== void 0) {
|
|
1104
|
-
options.photoSize = "Custom";
|
|
1105
|
-
if (maxWidth === void 0 || maxHeight === void 0) {
|
|
1106
|
-
options.maxSizeType = maxWidth === void 0 ? "Height" : "Width";
|
|
1107
|
-
options.maxSizeValue = maxWidth ?? maxHeight;
|
|
1108
|
-
} else {
|
|
1109
|
-
options.maxSizeType = "Dimension";
|
|
1110
|
-
options.maxSizeValue = Math.min(maxWidth, maxHeight);
|
|
1111
|
-
exact &&= maxWidth === maxHeight;
|
|
1112
|
-
}
|
|
1113
|
-
}
|
|
1114
|
-
return {
|
|
1115
|
-
exact,
|
|
1116
|
-
options
|
|
1117
|
-
};
|
|
1118
|
-
}
|
|
1119
1040
|
/**
|
|
1120
1041
|
* Export a photo, or every photo in an album, through the Photos.app export
|
|
1121
1042
|
* sheet, by automating its GUI with AppleScript.
|
|
@@ -1321,12 +1242,11 @@ async function exportApplePhotos(identifiers, destinationDirectory, options) {
|
|
|
1321
1242
|
const photoInfos = await resolveIdentifiers(identifiers);
|
|
1322
1243
|
const exportedPhotos = [];
|
|
1323
1244
|
for (const photoInfo of photoInfos) {
|
|
1324
|
-
const
|
|
1245
|
+
const engine = await getEngineForPhoto(photoInfo, resolvedOptions);
|
|
1325
1246
|
const exportedPhoto = {
|
|
1326
|
-
exportDegraded: degraded,
|
|
1327
1247
|
exportEngine: engine,
|
|
1328
1248
|
exportOptions: resolvedOptions,
|
|
1329
|
-
path:
|
|
1249
|
+
path: await exportPhotoWithEngine(photoInfo, engine, resolvedOptions),
|
|
1330
1250
|
photoInfo
|
|
1331
1251
|
};
|
|
1332
1252
|
const resolvedDestinationDirectory = await ensureDirectoryExists(destinationDirectory);
|
|
@@ -1343,40 +1263,21 @@ async function exportApplePhotos(identifiers, destinationDirectory, options) {
|
|
|
1343
1263
|
return exportedPhotos;
|
|
1344
1264
|
}
|
|
1345
1265
|
/**
|
|
1346
|
-
*
|
|
1347
|
-
*
|
|
1348
|
-
*
|
|
1266
|
+
* Export a photo through one engine.
|
|
1267
|
+
*
|
|
1268
|
+
* @returns The path of the exported file, in a new temporary directory.
|
|
1269
|
+
* @throws {Error} If the engine fails. No other engine is tried instead.
|
|
1349
1270
|
*/
|
|
1350
1271
|
async function exportPhotoWithEngine(photoInfo, engine, options) {
|
|
1351
1272
|
switch (engine) {
|
|
1352
|
-
case "applescript": return
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
};
|
|
1357
|
-
case "file-system": return {
|
|
1358
|
-
degraded: false,
|
|
1359
|
-
engine,
|
|
1360
|
-
path: await exportViaFileSystem(photoInfo)
|
|
1361
|
-
};
|
|
1362
|
-
case "photos-gui": return {
|
|
1363
|
-
degraded: false,
|
|
1364
|
-
engine,
|
|
1365
|
-
path: await exportViaPhotosGui(photoInfo, options.appleScriptGuiOptions)
|
|
1366
|
-
};
|
|
1367
|
-
case "swift-photokit": return {
|
|
1368
|
-
degraded: false,
|
|
1369
|
-
engine,
|
|
1370
|
-
path: await exportViaSwiftPhotoKit(photoInfo.uuid)
|
|
1371
|
-
};
|
|
1273
|
+
case "applescript": return exportViaAppleScript(photoInfo.uuid);
|
|
1274
|
+
case "file-system": return exportViaFileSystem(photoInfo);
|
|
1275
|
+
case "photos-gui": return exportViaPhotosGui(photoInfo, options.appleScriptGuiOptions);
|
|
1276
|
+
case "swift-photokit": return exportViaSwiftPhotoKit(photoInfo.uuid);
|
|
1372
1277
|
case "swift-render": try {
|
|
1373
|
-
return
|
|
1374
|
-
degraded: false,
|
|
1375
|
-
engine,
|
|
1376
|
-
path: await exportViaSwiftRender(photoInfo.uuid, options.swiftRenderOptions)
|
|
1377
|
-
};
|
|
1278
|
+
return await exportViaSwiftRender(photoInfo.uuid, options.swiftRenderOptions);
|
|
1378
1279
|
} catch (error) {
|
|
1379
|
-
|
|
1280
|
+
throw new Error(`Rendering photo "${photoInfo.title ?? photoInfo.uuid}" failed: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
|
|
1380
1281
|
}
|
|
1381
1282
|
}
|
|
1382
1283
|
}
|
|
@@ -1386,27 +1287,6 @@ async function exportViaPhotosGui(photoInfo, guiOptions) {
|
|
|
1386
1287
|
return exportedPath;
|
|
1387
1288
|
}
|
|
1388
1289
|
/**
|
|
1389
|
-
* Export a photo that failed to render through the Photos.app GUI instead.
|
|
1390
|
-
*
|
|
1391
|
-
* Rendering depends on private Photos APIs that a macOS update can break. The
|
|
1392
|
-
* export sheet drives the same renderer the slow way, so it is set up to match
|
|
1393
|
-
* the render options instead of `appleScriptGuiOptions`, which only supply the
|
|
1394
|
-
* settings that have no counterpart, like file naming.
|
|
1395
|
-
*/
|
|
1396
|
-
async function exportViaPhotosGuiInsteadOfRender(photoInfo, options, renderError) {
|
|
1397
|
-
const { exact, options: guiOptions } = getAppleScriptGuiOptionsForRender(options.swiftRenderOptions);
|
|
1398
|
-
const shortfall = [...rendersTransparency(options.swiftRenderOptions) && await originalHasTransparency(photoInfo) ? ["its transparency is flattened onto white"] : [], ...exact ? [] : ["the size or JPEG quality is only approximate"]];
|
|
1399
|
-
log.warn(`Rendering photo "${photoInfo.title ?? photoInfo.uuid}" failed, falling back to the Photos.app GUI: ${renderError instanceof Error ? renderError.message : String(renderError)}${shortfall.length === 0 ? "" : ` The GUI can't match the render options: ${shortfall.join(", and ")}. The photo will be exported again on the next sync.`}`);
|
|
1400
|
-
return {
|
|
1401
|
-
degraded: shortfall.length > 0,
|
|
1402
|
-
engine: "photos-gui",
|
|
1403
|
-
path: await exportViaPhotosGui(photoInfo, {
|
|
1404
|
-
...options.appleScriptGuiOptions,
|
|
1405
|
-
...guiOptions
|
|
1406
|
-
})
|
|
1407
|
-
};
|
|
1408
|
-
}
|
|
1409
|
-
/**
|
|
1410
1290
|
* Work out the path an exported photo should end up at: the directory and
|
|
1411
1291
|
* extension of `filePath`, with a file name chosen by the first naming strategy
|
|
1412
1292
|
* the photo has a value for.
|
|
@@ -1579,9 +1459,9 @@ async function resizePngToFit(imagePath, destinationDirectory, maxWidth, maxHeig
|
|
|
1579
1459
|
return destinationImagePath;
|
|
1580
1460
|
}
|
|
1581
1461
|
/**
|
|
1582
|
-
* Convert an image to a JPEG
|
|
1462
|
+
* Convert an image to a JPEG with mozjpeg, at a quality from 0 to 1
|
|
1583
1463
|
*/
|
|
1584
|
-
async function convertToJpeg(sourceImagePath, destinationDirectory, quality, force = false
|
|
1464
|
+
async function convertToJpeg(sourceImagePath, destinationDirectory, quality, force = false) {
|
|
1585
1465
|
const mime = lookupImageMimeType(sourceImagePath, [
|
|
1586
1466
|
"bmp",
|
|
1587
1467
|
"jpeg",
|
|
@@ -1592,49 +1472,31 @@ async function convertToJpeg(sourceImagePath, destinationDirectory, quality, for
|
|
|
1592
1472
|
const destinationImagePath = path.join(destinationDirectory, path.basename(sourceImagePath, path.extname(sourceImagePath)) + ".jpeg");
|
|
1593
1473
|
if (!force && mime === "jpeg") await fse.copy(sourceImagePath, destinationImagePath);
|
|
1594
1474
|
else {
|
|
1595
|
-
const
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
await execa("cjpeg", [
|
|
1610
|
-
...jpegQuality === "lossless" ? ["--lossless"] : ["-quality", jpegQuality.toString()],
|
|
1611
|
-
"-optimize",
|
|
1612
|
-
"-progressive",
|
|
1613
|
-
"-outfile",
|
|
1614
|
-
destinationImagePath,
|
|
1615
|
-
tgaImagePath
|
|
1616
|
-
]);
|
|
1617
|
-
await fse.rm(tgaTempDirectory, { recursive: true });
|
|
1618
|
-
break;
|
|
1619
|
-
}
|
|
1620
|
-
case "sips":
|
|
1621
|
-
if (jpegQuality === "lossless") throw new Error("Lossless JPEG conversion not supported with sips");
|
|
1622
|
-
await execa("sips", [
|
|
1623
|
-
"-s",
|
|
1624
|
-
"format",
|
|
1625
|
-
"jpeg",
|
|
1626
|
-
"-s",
|
|
1627
|
-
"formatOptions",
|
|
1628
|
-
jpegQuality.toString(),
|
|
1629
|
-
sourceImagePath,
|
|
1630
|
-
"--out",
|
|
1631
|
-
destinationImagePath
|
|
1632
|
-
]);
|
|
1633
|
-
}
|
|
1475
|
+
const cjpegPath = getMozjpegCjpegPath();
|
|
1476
|
+
if (!await fse.pathExists(cjpegPath)) throw new Error(`JPEG encoding needs mozjpeg, which was not found at "${cjpegPath}". Install it with "brew install mozjpeg".`);
|
|
1477
|
+
const tgaTempDirectory = await fse.mkdtemp(path.join(os.tmpdir(), `com.kitschpatrol.aphex.${getSlugFilename(sourceImagePath)}.mozjpeg.`));
|
|
1478
|
+
const tgaImagePath = await convertToTga(sourceImagePath, tgaTempDirectory);
|
|
1479
|
+
await execa(cjpegPath, [
|
|
1480
|
+
"-quality",
|
|
1481
|
+
Math.round(quality * 100).toString(),
|
|
1482
|
+
"-optimize",
|
|
1483
|
+
"-progressive",
|
|
1484
|
+
"-outfile",
|
|
1485
|
+
destinationImagePath,
|
|
1486
|
+
tgaImagePath
|
|
1487
|
+
]);
|
|
1488
|
+
await fse.rm(tgaTempDirectory, { recursive: true });
|
|
1634
1489
|
}
|
|
1635
1490
|
return destinationImagePath;
|
|
1636
1491
|
}
|
|
1637
1492
|
/**
|
|
1493
|
+
* Homebrew installs mozjpeg keg-only, so its `cjpeg` is not on the PATH. The
|
|
1494
|
+
* `cjpeg` that is comes from libjpeg-turbo, which ImageMagick depends on.
|
|
1495
|
+
*/
|
|
1496
|
+
function getMozjpegCjpegPath() {
|
|
1497
|
+
return path.join(process.env.HOMEBREW_PREFIX ?? "/opt/homebrew", "opt/mozjpeg/bin/cjpeg");
|
|
1498
|
+
}
|
|
1499
|
+
/**
|
|
1638
1500
|
* Convert an image to a WebP
|
|
1639
1501
|
*/
|
|
1640
1502
|
async function convertToWebp(sourceImagePath, destinationDirectory, quality, force = false) {
|
|
@@ -1808,7 +1670,7 @@ async function compressImage(sourceImagePath, destinationDirectory, options) {
|
|
|
1808
1670
|
workingImagePath = await convertToAvif(sourceImagePath, tempDirectory, lossyQuality, true);
|
|
1809
1671
|
break;
|
|
1810
1672
|
case "jpeg":
|
|
1811
|
-
workingImagePath = await convertToJpeg(sourceImagePath, tempDirectory, lossyQuality, true
|
|
1673
|
+
workingImagePath = await convertToJpeg(sourceImagePath, tempDirectory, lossyQuality, true);
|
|
1812
1674
|
break;
|
|
1813
1675
|
case "none":
|
|
1814
1676
|
workingImagePath = sourceImagePath;
|
|
@@ -2168,7 +2030,7 @@ async function isDifferent(diffStrategies, sourcePhotoInfo, sourcePhotoFileBaseN
|
|
|
2168
2030
|
case "exif-tags":
|
|
2169
2031
|
sourceTags ??= await getTags(sourcePhotoInfo.original.filePath);
|
|
2170
2032
|
return matchPhotoTags === void 0 || sourceTags.credit !== matchPhotoTags.credit || sourceTags.creator !== matchPhotoTags.creator || sourceTags.description !== matchPhotoTags.description || sourceTags.preservedFileName !== matchPhotoTags.preservedFileName || sourceTags.label !== matchPhotoTags.label;
|
|
2171
|
-
case "export-options": return matchPhotoTags === void 0 ||
|
|
2033
|
+
case "export-options": return matchPhotoTags === void 0 || !deepEqual(asStored(exportOptions.exportOptions), matchPhotoTags.aphexMetadata?.exportOptions.exportOptions);
|
|
2172
2034
|
case "file-name": return stripExtension(path.basename(matchPhotoFilePath)) !== sourcePhotoFileBaseName;
|
|
2173
2035
|
case "force-update": return true;
|
|
2174
2036
|
case "metadata-options":
|
|
@@ -2363,10 +2225,7 @@ async function getFileIdentity(filePath) {
|
|
|
2363
2225
|
}
|
|
2364
2226
|
}
|
|
2365
2227
|
function cleanExportResults(result) {
|
|
2366
|
-
return {
|
|
2367
|
-
exportDegraded: result.exportDegraded,
|
|
2368
|
-
exportEngine: result.exportEngine
|
|
2369
|
-
};
|
|
2228
|
+
return { exportEngine: result.exportEngine };
|
|
2370
2229
|
}
|
|
2371
2230
|
function cleanMetadataResults(result) {
|
|
2372
2231
|
const { photoInfo: _, ...rest } = result;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kitschpatrol/aphex",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Apple Photos Export. TypeScript library and CLI tool to export and process images and albums from your macOS Photos.app library.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"apple",
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
"pretty-ms": "^10.0.0",
|
|
74
74
|
"publint": "^0.3.25",
|
|
75
75
|
"shx": "^0.4.0",
|
|
76
|
-
"tsdown": "^0.23.
|
|
76
|
+
"tsdown": "^0.23.8",
|
|
77
77
|
"tsx": "^4.23.15",
|
|
78
78
|
"typescript": "~6.0.3",
|
|
79
79
|
"vitest": "^5.1.2"
|
package/readme.md
CHANGED
|
@@ -74,19 +74,18 @@ npm install @kitschpatrol/aphex
|
|
|
74
74
|
Full image processing functionality also requires a number of command-line tools available via [Homebrew](https://brew.sh):
|
|
75
75
|
|
|
76
76
|
```sh
|
|
77
|
-
brew install libavif mozjpeg imagemagick webp dssim ffmpeg
|
|
77
|
+
brew install libavif mozjpeg imagemagick webp dssim ffmpeg oxipng
|
|
78
78
|
```
|
|
79
79
|
|
|
80
|
-
| Tool | Used for
|
|
81
|
-
| ------------- |
|
|
82
|
-
| `libavif` | AVIF encoding
|
|
83
|
-
| `mozjpeg` | JPEG encoding
|
|
84
|
-
| `webp` | WebP encoding (lossy, lossless, and near-lossless)
|
|
85
|
-
| `oxipng` | PNG optimization
|
|
86
|
-
| `
|
|
87
|
-
| `
|
|
88
|
-
| `
|
|
89
|
-
| `dssim` | Perceptual similarity metrics (only needed if `logSimilarity` is enabled) |
|
|
80
|
+
| Tool | Used for |
|
|
81
|
+
| ------------- | ----------------------------------------------------------------------------------------------- |
|
|
82
|
+
| `libavif` | AVIF encoding |
|
|
83
|
+
| `mozjpeg` | JPEG encoding, run from `$HOMEBREW_PREFIX/opt/mozjpeg` because Homebrew keeps it off the `PATH` |
|
|
84
|
+
| `webp` | WebP encoding (lossy, lossless, and near-lossless) |
|
|
85
|
+
| `oxipng` | PNG optimization |
|
|
86
|
+
| `imagemagick` | Transparency checks, and resizing to fit `maxDimensionsPixels` |
|
|
87
|
+
| `ffmpeg` | SSIM and PSNR similarity metrics (only needed if `logSimilarity` is enabled) |
|
|
88
|
+
| `dssim` | Perceptual similarity metrics (only needed if `logSimilarity` is enabled) |
|
|
90
89
|
|
|
91
90
|
If you skip image processing (`processOptions: 'disabled'`) you can omit all of these but `imagemagick`, which is also used to check whether a photo has transparency when picking an export engine.
|
|
92
91
|
|
|
@@ -217,7 +216,7 @@ const result = await exportPhoto('Pets/Tiny', '~/Desktop', {
|
|
|
217
216
|
|
|
218
217
|
Some things to know about `swift-render`:
|
|
219
218
|
|
|
220
|
-
- It depends on private Photos APIs, so a macOS update can break it. It has been checked against Photos.app 10.0 on macOS 15.6 and Photos.app 12.0 on macOS 27.2. If a render fails
|
|
219
|
+
- It depends on private Photos APIs, so a macOS update can break it. It has been checked against Photos.app 10.0 on macOS 15.6 and Photos.app 12.0 on macOS 27.2. If a render fails, the export fails with an error that names the photo. Aphex doesn't switch to another engine on its own. To export such a photo anyway, choose a different engine for it, such as `swift-photokit` for the image stored in the library.
|
|
221
220
|
- Edits made with third-party editing extensions can't be rendered again, because only the extension understands its own edit data. For those photos the edited image stored in the library is converted instead, which is also what Photos.app does.
|
|
222
221
|
- With `includeMetadata` it writes the same title, caption, and keywords as Photos.app, but not the names of people identified in the photo. macOS doesn't let other apps read those from the library.
|
|
223
222
|
|
|
@@ -418,7 +417,7 @@ Aphex borrows a technique from [Andreas Bentele](https://github.com/abentele)'s
|
|
|
418
417
|
|
|
419
418
|
Please open an issue to discuss changes before submitting a pull request. Unsolicited PRs are unlikely to be merged.
|
|
420
419
|
|
|
421
|
-
This repository uses [ksc](https://github.com/kitschpatrol/shared-config) to handle linting and formatting with the usual tools, plus [mdat](https://github.com/kitschpatrol/mdat) for readme placeholder expansion,
|
|
420
|
+
This repository uses [ksc](https://github.com/kitschpatrol/shared-config) to handle linting and formatting with the usual tools, plus [mdat](https://github.com/kitschpatrol/mdat) for readme placeholder expansion, [chagent](https://github.com/kitschpatrol/chagent) to maintain the [changelog](changelog.md), and [brewpub](https://github.com/kitschpatrol/brewpub) to publish the Homebrew formula.
|
|
422
421
|
|
|
423
422
|
<!-- /contributing -->
|
|
424
423
|
|