Added AdjustmentsInfo, #150, #379

This commit is contained in:
Rhet Turnbull
2021-02-20 11:01:08 -08:00
parent b3a7869bd3
commit 5ee6affc05
7 changed files with 410 additions and 34 deletions

View File

@@ -31,6 +31,7 @@ OSXPhotos provides the ability to interact with and query Apple's Photos.app lib
+ [FaceInfo](#faceinfo)
+ [CommentInfo](#commentinfo)
+ [LikeInfo](#likeinfo)
+ [AdjustmentsInfo](#adjustmentsinfo)
+ [Raw Photos](#raw-photos)
+ [Template Substitutions](#template-substitutions)
+ [Utility Functions](#utility-functions)
@@ -1563,7 +1564,7 @@ Returns height of the photo in pixels. If image has been edited, returns height
Returns width of the photo in pixels. If image has been edited, returns width of the edited image, otherwise returns width of the original image. See also [original_width](#original_width).
#### `orientation`
Returns EXIF orientation value of the photo as integer. If image has been edited, returns orientation of the edited image, otherwise returns orientation of the original image. See also [original_orientation](#original_orientation).
Returns EXIF orientation value of the photo as integer. If image has been edited, returns orientation of the edited image, otherwise returns orientation of the original image. See also [original_orientation](#original_orientation). If orientation cannot be determined, returns 0 (this happens if osxphotos cannot decode the adjustment info for an edited image).
#### `original_height`
Returns height of the original photo in pixels. See also [height](#height).
@@ -1583,6 +1584,9 @@ Returns `True` if the original image file is missing on disk, otherwise `False`.
#### `hasadjustments`
Returns `True` if the picture has been edited, otherwise `False`
#### `adjustments`
On Photos 5+, returns an [AdjustmentsInfo](#adjustmentsinfo) object representing the adjustments (edits) to the photo or None if there are no adjustments. On earlier versions of Photos, always returns None.
#### `external_edit`
Returns `True` if the picture was edited in an external editor (outside Photos.app), otherwise `False`
@@ -2381,9 +2385,26 @@ Returns a JSON representation of the FaceInfo instance.
[PhotoInfo.likes](#likes) returns a list of LikeInfo objects for "likes" on shared photos. (Photos 5/MacOS 10.15+ only). The list of LikeInfo objects will be sorted in ascending order by date like was made. LikeInfo contains the following fields:
- `datetime`: `datetime.datetime`, date/time like was made
- `user`: `str`, name of user who made the like
- `user`: `str`, name of user who made the like
- `ismine`: `bool`, True if like was made by person who owns the Photos library being operated on
### AdjustmentsInfo
[PhotoInfo.adjustments](#adjustments) returns an AdjustmentsInfo object, if the photo has adjustments, or `None` if the photo does not have adjusments. AdjustmentsInfo has the following properties and methods:
- `plist`: The adjustments plist file maintained by Photos as a dict.
- `data`: The raw, undecoded adjustments info as binary blob.
- `editor`: The editor bundle ID of the app which made the edits, e.g. `com.apple.photos`.
- `format_id`: The format identifier set by the app which made the edits, e.g. `com.apple.photos`.
- `base_version`: Version info set by the app which made the edits.
- `format_version`: Version info set by the app which made the edits.
- `timestamp`: Time stamp of the adjustment as a timezone-aware datetime.datetime object; None if no timestamp is set.
- `adjustments`: a list of dicts containing information about the decoded adjustments to the photo or None if adjustments could not be decoded. AdjustmentsInfo can decode adjustments made by Photos but cannot decode adjustments made by external plugins or apps.
- `adj_metadata`: a dict containing additional data about the photo decoded from the adjustment data.
- `adj_orientation`: the EXIF orientation of the edited photo decoded from the adjustment metadata.
- `adj_format_version`: version for adjustments format decoded from the adjustment data.
- `adj_version_info`: version info for the application which made the adjustments to the photo decoded from the adjustments data.
- `asdict()`: dict representation of the AdjustmentsInfo object; contains all properties with exception of `plist`.
### Raw Photos
Handling raw photos in `osxphotos` requires a bit of extra work. Raw photos in Photos can be imported in two different ways: 1) a single raw photo with no associated JPEG image is imported 2) a raw+JPEG pair is imported -- two separate images with same file stem (e.g. `IMG_0001.CR2` and `IMG_001.JPG`) are imported.