Updated export example
This commit is contained in:
54
README.md
54
README.md
@@ -129,6 +129,35 @@ if __name__ == "__main__":
|
|||||||
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
|
## Module Interface
|
||||||
|
|
||||||
### Utility Functions
|
### 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
|
## 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.
|
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.
|
||||||
|
|||||||
@@ -6,17 +6,21 @@ import os.path
|
|||||||
|
|
||||||
import osxphotos
|
import osxphotos
|
||||||
|
|
||||||
photosdb = osxphotos.PhotosDB()
|
def main():
|
||||||
photos = photosdb.photos()
|
photosdb = osxphotos.PhotosDB()
|
||||||
|
photos = photosdb.photos()
|
||||||
|
|
||||||
export_path = os.path.expanduser("~/Desktop/export")
|
export_path = os.path.expanduser("~/Desktop/export")
|
||||||
|
|
||||||
for p in photos:
|
for p in photos:
|
||||||
if not p.ismissing():
|
if not p.ismissing():
|
||||||
if p.hasadjustments():
|
if p.hasadjustments():
|
||||||
exported = p.export(export_path, edited=True)
|
exported = p.export(export_path, edited=True)
|
||||||
|
else:
|
||||||
|
exported = p.export(export_path)
|
||||||
|
print(f"Exported {p.filename()} to {exported}")
|
||||||
else:
|
else:
|
||||||
exported = p.export(export_path)
|
print(f"Skipping missing photo: {p.filename()}")
|
||||||
print(f"Exported {p.filename()} to {exported}")
|
|
||||||
else:
|
if __name__ == "__main__":
|
||||||
print(f"Skipping missing photo: {p.filename()}")
|
main()
|
||||||
Reference in New Issue
Block a user