[View]  [Edit]  [Lock]  [References]  [Attachments]  [History]  [Home]  [Changes]  [Search]  [Help] 

test[photos8] 03 Accessing image




"Capture icon of image asset"
| favorites asset result |
favorites := (PHAsset
	in: (PHAssetCollection smartAlbum: #Favorites))
	select: [:one| one mediaTypeSelector = #image ].
favorites isEmpty ifTrue: [
	^self error: 'We need an image in favorites to perform this test'
].

asset := favorites first.
PHImageManager default
	withImageForAsset: asset ofSize: CGSize @ 120
	do: [:image :info| result := image ].
self print: '// image capture got icon of size ' ,result size asPoint.



"Capture icon of video asset"
| favorites asset result |
favorites := (PHAsset
	in: (PHAssetCollection smartAlbum: #Favorites))
	select: [:one| one mediaTypeSelector = #video ].
favorites isEmpty ifTrue: [
	^self error: 'We need a video in favorites to perform this test'
].

asset := favorites first.
PHImageManager default
	withImageForAsset: asset ofSize: CGSize @ 120
	do: [:image :info| result := image ].
self print: '// image capture got icon of size ' ,result size asPoint.