Reference
PhotoLibrary
Interface to PhotoKit PHImageManager and PHPhotoLibrary
Source code in photokit/photolibrary.py
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 |
|
__init__(library_path=None)
Initialize ImageManager instance. Requests authorization to use the Photos library if authorization has not already been granted.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
library_path |
str | None
|
str, path to Photos library to use; if None, uses default shared library |
None
|
Note
Access to the default shared library is provided via documented PhotoKit APIs. Access to other libraries via library_path is provided via undocumented private PhotoKit APIs. Thus this may break at any time.
Source code in photokit/photolibrary.py
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
|
__len__()
Return number of assets in library
Source code in photokit/photolibrary.py
1071 1072 1073 |
|
add_live_photo(photo_path, video_path)
Add a live photo/video pair to the Photos library
Parameters:
Name | Type | Description | Default |
---|---|---|---|
photo_path |
str | Path | PathLike
|
path to image file to add |
required |
video_path |
str | Path | PathLike
|
path to paired video file to add |
required |
Returns:
Type | Description |
---|---|
LivePhotoAsset
|
LivePhotoAsset object for added live photo/video pair |
Source code in photokit/photolibrary.py
618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 |
|
add_photo(photo_path)
Add a photo to the Photos library
Parameters:
Name | Type | Description | Default |
---|---|---|---|
photo_path |
str | Path | PathLike
|
path to image file to add |
required |
Returns:
Type | Description |
---|---|
PhotoAsset
|
PhotoAsset object for added photo |
Source code in photokit/photolibrary.py
582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 |
|
add_raw_pair_photo(raw_path, jpeg_path)
Add a RAW+JPEG pair to the Photos library
Parameters:
Name | Type | Description | Default |
---|---|---|---|
raw_path |
str | Path | PathLike
|
path to RAW image file to add |
required |
jpeg_path |
str | Path | PathLike
|
path to paired JPEG file to add |
required |
Returns:
Type | Description |
---|---|
LivePhotoAsset
|
PhotoAsset object for added photo pair |
Note
The JPEG image will be treated as the "Original" image in Photos and the paired RAW will be considered the alternate image. This is consistent with Photos default behavior.
Source code in photokit/photolibrary.py
648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 |
|
add_video(video_path)
Add a video to the Photos library
Parameters:
Name | Type | Description | Default |
---|---|---|---|
video_path |
str | Path | PathLike
|
path to video file to add |
required |
Returns:
Type | Description |
---|---|
VideoAsset
|
VideoAsset object for added photo |
Source code in photokit/photolibrary.py
600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 |
|
album(uuid=None, title=None)
Get Album by UUID or name
Parameters:
Name | Type | Description | Default |
---|---|---|---|
uuid |
str | None
|
str | None; UUID of album to fetch |
None
|
title |
str | None
|
str | None; title/name of album to fetch |
None
|
Returns: Album object
Note: You must pass only one of uuid or title, not both. If more than one album has the same title, the behavior is undefined; one of the albums will be returned but no guarantee is made as to which one.
Source code in photokit/photolibrary.py
360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 |
|
albums(top_level=False)
Return list of albums in the library
Parameters:
Name | Type | Description | Default |
---|---|---|---|
top_level |
bool
|
if True, return only top level albums |
False
|
Returns: list of Album objects
Source code in photokit/photolibrary.py
321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 |
|
asset(uuid)
Return Asset with uuid = uuid
Parameters:
Name | Type | Description | Default |
---|---|---|---|
uuid |
str
|
str; UUID of image asset to fetch |
required |
Returns:
Type | Description |
---|---|
Asset
|
PhotoAsset object |
Note
uuid may be a UUID or the full local identifier of the requested asset
Source code in photokit/photolibrary.py
500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 |
|
assets(uuids=None)
Return list of all assets in the library or subset filtered by UUID.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
uuids |
list[str] | None
|
(list[str]) UUID of image assets to fetch; if None, fetch all assets |
None
|
Returns: list of Asset objects
Note: Does not currently return assets that are hidden or in trash nor non-selected burst assets
Source code in photokit/photolibrary.py
294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 |
|
authorization_status()
staticmethod
Get authorization status to use user's Photos Library
Returns: tuple of bool for (read_write, add_only) authorization status
Source code in photokit/photolibrary.py
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 |
|
create_album(title)
Create a new album in the library
Parameters:
Name | Type | Description | Default |
---|---|---|---|
title |
str
|
str, title of new album |
required |
Returns: Album object for new album
Source code in photokit/photolibrary.py
398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 |
|
create_keyword(keyword)
Add a new keyword to the Photos library.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
keyword |
str
|
str, keyword to add |
required |
Returns: PHKeyword object for new keyword
Note: this does not add the keyword to any assets; it only creates the keyword in the library. Keywords must be created in the library before they can be added to assets.
In general you should be able to use Asset().keywords setter to add a keyword to an asset without calling this method directly.
Source code in photokit/photolibrary.py
757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 |
|
create_library(library_path)
staticmethod
Create a new Photos library at library_path
Parameters:
Name | Type | Description | Default |
---|---|---|---|
library_path |
str | Path | PathLike
|
str or pathlib.Path, path to new library |
required |
Returns: PhotoLibrary object for new library
Note
This only works in multi-library mode; multi-library mode will be enabled if not already enabled. This may file (after a long timeout) if a library with same name was recently created (even if it has since been deleted).
Source code in photokit/photolibrary.py
248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 |
|
delete_album(album)
Delete album in the library
Parameters:
Name | Type | Description | Default |
---|---|---|---|
album |
Album
|
Album object to delete |
required |
Source code in photokit/photolibrary.py
442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 |
|
delete_assets(photoassets)
Delete assets.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
photoassets |
list[PhotoAsset]
|
list of PhotoAsset objects to delete |
required |
Note that this will prompt the user to confirm deletion of assets.
Source code in photokit/photolibrary.py
552 553 554 555 556 557 558 559 560 561 562 563 |
|
enable_multi_library_mode()
staticmethod
Enable multi-library mode. This is a no-op if already enabled.
Note
Some PhotoKit APIs only work in multi-library mode. Once enabled, it cannot be disabled and only single-library mode APIs will work. In practice, you should not need to use this and PhotoLibrary will manage this automatically.
Source code in photokit/photolibrary.py
140 141 142 143 144 145 146 147 148 149 150 151 |
|
fetch_burst_uuid(burstid, all=False)
fetch PhotoAssets with burst ID = burstid
Parameters:
Name | Type | Description | Default |
---|---|---|---|
burstid |
str, burst UUID |
required | |
all |
return all burst assets; if False returns only those selected by the user (including the "key photo" even if user hasn't manually selected it) |
False
|
Returns:
Type | Description |
---|---|
list of PhotoAsset objects |
Source code in photokit/photolibrary.py
523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 |
|
folders()
"Return list of folders in the library
Source code in photokit/photolibrary.py
475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 |
|
library_path()
Return path to Photos library
Source code in photokit/photolibrary.py
290 291 292 |
|
multi_library_mode()
staticmethod
Return True if multi-library mode is enabled, False otherwise
Source code in photokit/photolibrary.py
153 154 155 156 |
|
request_authorization(access_level=PHAccessLevelReadWrite)
staticmethod
Request authorization to user's Photos Library
Parameters:
Name | Type | Description | Default |
---|---|---|---|
access_level |
int
|
(int) PHAccessLevelAddOnly or PHAccessLevelReadWrite |
PHAccessLevelReadWrite
|
Returns: True if authorization granted, False otherwise
In actual practice, the terminal process running the python code
will do the actual request. This method exists for use in bundled apps created with py2app, etc. It has not yet been well tested.
Source code in photokit/photolibrary.py
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 |
|
smart_album(album_name=None, album_type=None, user=False)
Get smart album with given name
Parameters:
Name | Type | Description | Default |
---|---|---|---|
album_name |
str | None
|
name of smart album to fetch |
None
|
album_type |
PhotoLibrarySmartAlbumType | None
|
PhotoLibrarySmartAlbumType of smart album to fetch |
None
|
user |
bool
|
if True, fetch user smart album instead of system smart album |
False
|
Returns: Album object for smart album
Note: This only works in single library mode. If more than one album has the same name, the first one found will be returned but no guarantee is made as to which one.
Source code in photokit/photolibrary.py
810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 |
|
smart_albums(user=False)
Get list of smart albums
Parameters:
Name | Type | Description | Default |
---|---|---|---|
user |
bool
|
if True, fetch user smart albums instead of system smart albums |
False
|
Returns: list of Album objects for smart albums
Note: This only works in single library mode
Source code in photokit/photolibrary.py
876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 |
|
system_photo_library_path()
staticmethod
Return path to system photo library
Source code in photokit/photolibrary.py
158 159 160 161 |
|
PhotoLibrarySmartAlbumType
Bases: Enum
Smart album types. The following are supported:
- Favorites
- Hidden
- Animated
- Bursts
- Cinematics
- Portraits
- Generic
- LivePhotos
- LongExposures
- Panoramas
- RAW
- RecentlyAdded
- Screenshots
- Selfies
- SlowMos
- TimeLapses
- UnableToUload
- UserLibrary
- Videos
Source code in photokit/photolibrary.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
|
PhotoAsset
Bases: Asset
PhotoKit PHAsset representation
Source code in photokit/asset.py
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 |
|
burst
property
return True if image is burst otherwise False
burstid
property
return burstIdentifier of image if image is burst photo otherwise None
date: datetime.datetime
property
writable
date asset was created as a naive datetime.datetime
date_added: datetime.datetime
property
writable
date asset was added to the library as a naive datetime.datetime
date_modified: datetime.datetime
property
writable
date asset was modified as a naive datetime.datetime
degraded
property
Return True if asset is degraded version
Parameters:
Name | Type | Description | Default |
---|---|---|---|
version |
which version of image (PHImageRequestOptionsVersionOriginal or PHImageRequestOptionsVersionCurrent) |
required |
duration: float
property
duration of the asset in seconds
favorite: bool
property
writable
True if asset is favorite, otherwise False
hasadjustments
property
Check to see if a PHAsset has adjustment data associated with it Returns False if no adjustments, True if any adjustments
hdr
property
return True if asset is HDR, otherwise False
hidden
property
writable
True if asset is hidden, otherwise False
isaudio
property
Return True if asset is audio, otherwise False
ismovie
property
Return True if asset is movie (video), otherwise False
isphoto
property
Return True if asset is photo (image), otherwise False
keywords: list[str]
property
writable
Keywords associated with asset
live
property
return True if asset is live, otherwise False
local_identifier
property
Return local identifier of PHAsset
location: tuple[float, float] | None
property
writable
location of the asset as a tuple of (latitude, longitude) or None if no location
media_subtypes
property
media subtype
media_type
property
media type such as image or video
original_filename
property
Return original filename asset was imported with
panorama
property
return True if asset is panorama, otherwise False
phasset
property
Return PHAsset instance
pixel_height
property
height in pixels
pixel_width
property
width in pixels
portrait
property
return True if asset is portrait (depth effect), otherwise False
raw_filename
property
Return RAW filename for RAW+JPEG photos or None if no RAW asset
screenshot
property
return True if asset is screenshot, otherwise False
slow_mo
property
return True if asset is slow motion (high frame rate) video, otherwise False
source_type
property
the means by which the asset entered the user's library
streamed
property
return True if asset is streamed video, otherwise False
time_lapse
property
return True if asset is time lapse video, otherwise False
timezone: str
property
writable
The named timezone of the asset
timezone_offset: int
property
writable
Timezone offset (seconds from GMT) of the asset
uuid
property
Return UUID of PHAsset. This is the same as the local identifier minus the added path component.
__init__(library, phasset)
Return a PhotoAsset object
Parameters:
Name | Type | Description | Default |
---|---|---|---|
library |
PhotoLibrary
|
a PhotoLibrary object |
required |
phasset |
PHAsset
|
a PHAsset object |
required |
Source code in photokit/asset.py
128 129 130 131 132 133 134 135 136 137 |
|
export(dest, filename=None, version=PHImageRequestOptionsVersionCurrent, overwrite=False, raw=False, **kwargs)
Export image to path
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dest |
str, path to destination directory |
required | |
filename |
str, optional name of exported file; if not provided, defaults to asset's original filename |
None
|
|
version |
which version of image (PHImageRequestOptionsVersionOriginal or PHImageRequestOptionsVersionCurrent) |
PHImageRequestOptionsVersionCurrent
|
|
overwrite |
bool, if True, overwrites destination file if it already exists; default is False |
False
|
|
raw |
bool, if True, export RAW component of RAW+JPEG pair, default is False |
False
|
|
**kwargs |
used only to avoid issues with each asset type having slightly different export arguments |
{}
|
Returns:
Type | Description |
---|---|
List of path to exported image(s) |
Source code in photokit/asset.py
588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 |
|
metadata(version=PHImageRequestOptionsVersionCurrent)
Return dict of asset metadata
Parameters:
Name | Type | Description | Default |
---|---|---|---|
version |
which version of image (PHImageRequestOptionsVersionOriginal or PHImageRequestOptionsVersionCurrent) |
PHImageRequestOptionsVersionCurrent
|
Source code in photokit/asset.py
480 481 482 483 484 485 486 487 |
|
orientation(version=PHImageRequestOptionsVersionCurrent)
Return orientation of asset
Parameters:
Name | Type | Description | Default |
---|---|---|---|
version |
which version of image (PHImageRequestOptionsVersionOriginal or PHImageRequestOptionsVersionCurrent) |
PHImageRequestOptionsVersionCurrent
|
Source code in photokit/asset.py
528 529 530 531 532 533 534 535 |
|
path(version=PHImageRequestOptionsVersionCurrent)
Return path of asset
Parameters:
Name | Type | Description | Default |
---|---|---|---|
version |
which version of image (PHImageRequestOptionsVersionOriginal or PHImageRequestOptionsVersionCurrent) |
PHImageRequestOptionsVersionCurrent
|
Source code in photokit/asset.py
518 519 520 521 522 523 524 525 526 |
|
url(version=PHImageRequestOptionsVersionCurrent)
Return URL of asset
Parameters:
Name | Type | Description | Default |
---|---|---|---|
version |
which version of image (PHImageRequestOptionsVersionOriginal or PHImageRequestOptionsVersionCurrent) |
PHImageRequestOptionsVersionCurrent
|
Source code in photokit/asset.py
509 510 511 512 513 514 515 516 |
|
uti(version=PHImageRequestOptionsVersionCurrent)
Return UTI of asset
Parameters:
Name | Type | Description | Default |
---|---|---|---|
version |
which version of image (PHImageRequestOptionsVersionOriginal or PHImageRequestOptionsVersionCurrent) |
PHImageRequestOptionsVersionCurrent
|
Source code in photokit/asset.py
489 490 491 492 493 494 495 496 |
|
uti_raw()
Return UTI of RAW component of RAW+JPEG pair
Source code in photokit/asset.py
498 499 500 501 502 503 504 505 506 507 |
|
LivePhotoAsset
Bases: PhotoAsset
Represents a live photo
Source code in photokit/asset.py
1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 |
|
export(dest, filename=None, version=PHImageRequestOptionsVersionCurrent, overwrite=False, photo=True, video=True, **kwargs)
Export image to path
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dest |
str, path to destination directory |
required | |
filename |
str, optional name of exported file; if not provided, defaults to asset's original filename |
None
|
|
version |
which version of image (PHImageRequestOptionsVersionOriginal or PHImageRequestOptionsVersionCurrent) |
PHImageRequestOptionsVersionCurrent
|
|
overwrite |
bool, if True, overwrites destination file if it already exists; default is False |
False
|
|
photo |
bool, if True, export photo component of live photo |
True
|
|
video |
bool, if True, export live video component of live photo |
True
|
|
**kwargs |
used only to avoid issues with each asset type having slightly different export arguments |
{}
|
Returns:
Type | Description |
---|---|
list of [path to exported image and/or video] |
Source code in photokit/asset.py
1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 |
|
VideoAsset
Bases: PhotoAsset
PhotoKit PHAsset representation of video asset
Source code in photokit/asset.py
901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 |
|
export(dest, filename=None, version=PHImageRequestOptionsVersionCurrent, overwrite=False, **kwargs)
Export video to path
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dest |
str, path to destination directory |
required | |
filename |
str, optional name of exported file; if not provided, defaults to asset's original filename |
None
|
|
version |
which version of image (PHImageRequestOptionsVersionOriginal or PHImageRequestOptionsVersionCurrent) |
PHImageRequestOptionsVersionCurrent
|
|
overwrite |
bool, if True, overwrites destination file if it already exists; default is False |
False
|
|
**kwargs |
used only to avoid issues with each asset type having slightly different export arguments |
{}
|
Returns:
Type | Description |
---|---|
List of path to exported image(s) |
Source code in photokit/asset.py
909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 |
|
Album
Represents a PHAssetCollection
Source code in photokit/album.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
|
approximate_location: Photos.CLLocation
property
Return the approximate location of the underlying PHAssetCollection
collection: Photos.PHAssetCollection
property
Return the underlying PHAssetCollection
end_date: datetime.datetime | None
property
Return the end date of the underlying PHAssetCollection as a naive datetime.datetime or None if no end date
estimated_count: int
property
Return the estimated number of assets in the underlying PHAssetCollection
local_identifier: str
property
Return the local identifier of the underlying PHAssetCollection
location_names: list[str]
property
Return the location names of the underlying PHAssetCollection
start_date: datetime.datetime | None
property
Return the start date of the underlying PHAssetCollection as a naive datetime.datetime or None if no start date
title: str
property
Return the localized title of the underlying PHAssetCollection
uuid: str
property
"Return the UUID of the underlying PHAssetCollection
__init__(library, collection)
Initialize Album object with a PHAssetCollection
Source code in photokit/album.py
23 24 25 26 27 28 |
|
__len__()
Return number of assets in the album
Source code in photokit/album.py
155 156 157 |
|
__repr__()
Return string representation of Album object
Source code in photokit/album.py
147 148 149 |
|
__str__()
Return string representation of Album object
Source code in photokit/album.py
151 152 153 |
|
add_assets(assets)
Add assets to the underlying album
Parameters:
Name | Type | Description | Default |
---|---|---|---|
assets |
list[Asset]
|
list of Asset objects to add to the album |
required |
Source code in photokit/album.py
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
|
assets()
Return a list of PHAssets in the underlying PHAssetCollection
Source code in photokit/album.py
77 78 79 80 81 82 83 84 85 |
|
remove_assets(assets)
Remove assets from the underlying album
Parameters:
Name | Type | Description | Default |
---|---|---|---|
assets |
list[Asset]
|
list of Asset objects to remove from the album |
required |
Source code in photokit/album.py
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
|