En AppleScript, je peux exporter des photos depuis Apple Photos. Il existe deux options :
- l'utilisation d'originaux ce qui annule toutes les modifications que j'ai faites.
- n'utilisant pas d'originaux, qui les exporte avec une qualité de 100%.
L'exportation en qualité 100% est pratiquement non compressée, même si la photo originale est plus compressée. Cela finit par prendre plus que l'original, ce qui revient à suréchantillonner la photo, sans aucun avantage supplémentaire.
Est-il possible de conserver la qualité d'origine, mais de ne pas perdre les modifications apportées dans Photos ?
Notez qu'un bouton pour la qualité existe dans Photos, comme dans la capture d'écran ci-dessous.
EDIT
J'ai fini par écrire et utiliser ceci. Notez que cela fait toujours PAS ne résout pas mon problème, comme expliqué dans les commentaires, mais il me donne une approximation convenable.
(*
Export Apple Photos
===================
Exports all photos in Apple Photos library and reduces them to 90% quality.
The photos are in their current version (as opposed to the original).
Quality reduction is done with `mogrify` as setting the quality isn't
possible (nor it is possible to get the current quality -- everything
gets exported at 100%). For more on this issue see [1].
TODO
----
* Albums in the top folder (i.e. outside any folder) aren't exported.
Only albums in folders are exported. To list them run this::
tell application "Photos"
repeat with alb in albums
log (get name of alb)
end repeat
end tell
References
----------
[1] https://apple.stackexchange.com/questions/410229/applescript-photos-export-quality
*)
-- main
tell application "Photos"
repeat with topFolder in folders
my processFolder(topFolder, 0, (get name of topFolder))
end repeat
end tell
-- recursively scan folders and export albums
on processFolder(fold, level, dirpath)
tell application "Photos"
log "Folder " & (get name of fold)
repeat with subFolder in (get folders of fold)
set subPath to dirpath & "/" & (get name of subFolder)
my exportAlbum(subFolder, subPath)
my processFolder(subFolder, level + 1, subPath)
end repeat
my exportAlbum(fold, dirpath)
end tell
end processFolder
-- export all albums in folder `f`
on exportAlbum(f, relativePath)
set dest to "/Volumes/DATA/ApplePhotos/" as POSIX file as text -- the destination folder (use a valid path)
tell application "Photos"
repeat with i in (get albums of f)
set tFolder to (the POSIX path of (dest as string) & relativePath & "/" & (get name of i)) as POSIX file as text
repeat 1 times
tell application "Finder"
if exists tFolder then
log "Skipping album " & (get name of i)
exit repeat
end if
end tell
log "Album " & (get name of i) & " -> " & tFolder as POSIX file as text
my makeFolder(tFolder) -- create a folder named (the name of this album) in dest
with timeout of 120 * 60 seconds -- 2 hours
export (get media items of i) to (tFolder as alias) without using originals
my reduceSize(tFolder)
end timeout
end repeat
end repeat
end tell
end exportAlbum
-- util mkdir
on makeFolder(tPath)
do shell script "mkdir -p " & quoted form of POSIX path of tPath
end makeFolder
-- util shell script to reduce file size (quality 90)
-- note: it checks folder is not empty, otherwise mogrify will fail.
on reduceSize(tPath)
set dirpath to quoted form of POSIX path of tPath & "/*.jpeg"
do shell script "ls " & dirpath & "; if [ $? -eq 0 ]; then /usr/local/bin/mogrify -quality 90 " & dirpath & "; else echo No files in folder " & dirpath & "; fi"
end reduceSize