Updated export example

This commit is contained in:
Rhet Turnbull
2019-12-14 10:35:39 -08:00
parent 800daf3658
commit bf8aed69cf
2 changed files with 44 additions and 36 deletions

View File

@@ -129,6 +129,35 @@ if __name__ == "__main__":
main()
```
```python
""" Export all photos to ~/Desktop/export
If file has been edited, export the edited version,
otherwise, export the original version """
import os.path
import osxphotos
def main():
photosdb = osxphotos.PhotosDB()
photos = photosdb.photos()
export_path = os.path.expanduser("~/Desktop/export")
for p in photos:
if not p.ismissing():
if p.hasadjustments():
exported = p.export(export_path, edited=True)
else:
exported = p.export(export_path)
print(f"Exported {p.filename()} to {exported}")
else:
print(f"Skipping missing photo: {p.filename()}")
if __name__ == "__main__":
main()
```
## Module Interface
### Utility Functions
@@ -447,31 +476,6 @@ for p in photos:
)
```
```python
""" Export all photos to ~/Desktop/export
If file has been edited, export the edited version,
otherwise, export the original version """
import os.path
import osxphotos
photosdb = osxphotos.PhotosDB()
photos = photosdb.photos()
export_path = os.path.expanduser("~/Desktop/export")
for p in photos:
if not p.ismissing():
if p.hasadjustments():
exported = p.export(export_path, edited=True)
else:
exported = p.export(export_path)
print(f"Exported {p.filename()} to {exported}")
else:
print(f"Skipping missing photo: {p.filename()}")
```
## History
This project started as a command line utility, `photosmeta`, available at [photosmeta](https://github.com/RhetTbull/photosmeta) This module converts the photosmeta Photos library query functionality into a module.