En AppleScript, puedo exportar fotos desde Apple Photos. Hay dos opciones:
- utilizando los originales que descarta todas las modificaciones que he hecho
- sin utilizar los originales, que los exporta con una calidad del 100%.
La exportación a una calidad del 100% está prácticamente sin comprimir, incluso cuando la foto original está más comprimida. Esto acaba llevando más espacio que el original, lo que supone un aumento de la muestra de la foto, sin ningún beneficio adicional.
¿Es posible mantener la calidad original, pero no perder las ediciones realizadas en Fotos?
Tenga en cuenta que existe un interruptor para la calidad en Fotos, según la captura de pantalla siguiente.
EDITAR
Terminé escribiendo y usando esto. Tenga en cuenta que esto todavía NO resolver mi problema, como se explica en los comentarios, pero me da una aproximación adecuada.
(*
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