๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
๐ŸŽ iOS

[Swift] PhotoKit ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์‚ฌ์šฉํ•˜๊ธฐ

by ํ‹ด๋”” 2021. 4. 2.
728x90
๋ฐ˜์‘ํ˜•

์ƒ๊ฐํ–ˆ๋˜ ๊ฒƒ ๋ณด๋‹ค ํ›จ์”ฌ ๋ฐฉ๋Œ€ํ•œ ๋‚ด์šฉ์ด๋ผ ์ •๋ฆฌ๊ฐ€ ํ•„์š”ํ•ด ๋ณด์—ฌ์„œ ํฌ์ŠคํŒ… ํ•ด๋ด…๋‹ˆ๋‹ค. 

ํด๋ž˜์Šค, Privacy, ์ด๋ฏธ์ง€ ๊ฐ€์ ธ์˜ค๊ธฐ ์ˆœ์œผ๋กœ ์‚ดํŽด ๋ณผ ๊นŒ ํ•ฉ๋‹ˆ๋‹ค.


์ปจํ…์ธ  ๋ชฉ๋ก


ํด๋ž˜์Šค ์•Œ์•„๋ณด๊ธฐ

Privacy ๊ฐค๋Ÿฌ๋ฆฌ ์ ‘๊ทผ ์‚ฌ์šฉ์ž ๊ถŒํ•œ (์•„์ง ์ž‘์„ฑ์ค‘)

์ธ๋„ค์ผ ์ด๋ฏธ์ง€ ๊ฐ€์ ธ์˜ค๊ธฐ

์›๋ณธ ์ด๋ฏธ์ง€ ๊ฐ€์ ธ์˜ค๊ธฐ

 


ํด๋ž˜์Šค ์•Œ์•„๋ณด๊ธฐ

PHAsset : PHObject

ํฌํ†  ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ์—์„œ ํ•˜๋‚˜์˜ ์ด๋ฏธ์ง€๋‚˜ ๋น„๋””์˜ค, ๋ผ์ด๋ธŒ ํฌํ† ๋ฅผ ํ‘œํ˜„ํ•œ๋‹ค. ์—์…‹์€ ์ด๋ฏธ์ง€๋‚˜ ๋น„๋””์˜ค์— ๋Œ€ํ•œ ๋ฉ”ํƒ€ ๋ฐ์ดํ„ฐ๋ฅผ ํฌํ•จํ•œ๋‹ค. 

static ๋ฉ”์†Œ๋“œ์ธ fecthAssets์€ PHFetchResult๋ฅผ ๋ฐ˜ํ™˜ํ•œ๋‹ค.

๋ฉ”ํƒ€๋ฐ์ดํ„ฐ๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ์ด์œ ๋Š” ์ด๋ฏธ์ง€ ์ž์ฒด๋ฅผ ๋ถˆ๋Ÿฌ์˜ค๋ ค๋ฉด ์•„์ฃผ ๋งŽ์€ ๋ฉ”๋ชจ๋ฆฌ์™€ ์ž์›์ด ํ•„์š”ํ•˜๋‹ค. ๋”ฐ๋ผ์„œ ๊ฒฝ์šฐ์— ๋”ฐ๋ผ ๋งŽ์€ ์ด๋ฏธ์ง€๋ฅผ ๋ถˆ๋Ÿฌ์˜ค๋ฉด ํฌ๋ž˜์‰ฌ ๋˜๋Š” ์ผ์ด ๋ฐœ์ƒ ํ•  ์ˆ˜ ์žˆ๋‹ค. 

์—ฌ๊ธฐ์—๋Š” ์‹ค์ œ ์ด๋ฏธ์ง€๋ฅผ ๋ฐ˜ํ™˜ ๋ฐ›์„ ์ˆ˜ ์žˆ๋Š” ์ •๋ณด๋„ ํฌํ•จ๋œ๋‹ค. ์ด๋ฏธ์ง€๋ฅผ ๋ฐ˜ํ™˜ ๋ฐ›์œผ๋ ค ํ•  ๋•Œ PHImageManager๊ฐ€ ํ•„์š”ํ•˜๋‹ค. 

 

PHImageManager

๊ตฌ์ฒด์ ์ธ ์ด๋ฏธ์ง€์™€ ๋น„๋””์˜ค๋ฅผ PHAsset ์ธ์Šคํ„ด์Šค๋กœ๋ถ€ํ„ฐ ์ ‘๊ทผํ•  ์ˆ˜ ์žˆ๋‹ค. 

PHCachingImageManager๋Š” ์ด๋ฏธ์ง€ ์บ์‹ฑ์— ๋Œ€ํ•œ ๋ ˆ๋ฒ„๋Ÿฌ์ง€๋ฅผ ์ด์šฉํ•  ์ˆ˜ ์žˆ๋‹ค. 

developer.apple.com/documentation/photokit/phimagemanager?language=objc

PHFetchResult

fetch ๋ฆฌํ€˜์ŠคํŠธ๋กœ ๋ถ€ํ„ฐ PHAsses์„ ์ฝœ๋ ‰์…˜์œผ๋กœ ๋‹ด๊ณ  ์žˆ๋‹ค. 

 

PHFetchOptions

์–ด๋–ค ์—์…‹์„ ์ƒ์„ฑํ•˜๊ณ  ํ•„ํ„ฐ๋ง ํ•  ๊ฒƒ์ธ์ง€์— ๋Œ€ํ•ด ์„ ํƒํ•˜๊ฑฐ๋‚˜ ๋ฐ”๊ฟ€ ์ˆ˜ ์žˆ๋‹ค.

 

PHPhotoLibrary

์ •๋ณด๋ฅผ ์š”์ฒญํ•˜๊ณ  ๊ฐค๋Ÿฌ๋ฆฌ๋ฅผ ๋ฐ”๊ฟ€ ์ˆ˜ ์žˆ๋‹ค. ๋˜ํ•œ ๋ฉ”์†Œ๋“œ๋ฅผ ์‚ฌ์šฉํ•ด์„œ ๊ฐค๋Ÿฌ๋ฆฌ์— ์ ‘๊ทผํ•  ์ˆ˜ ์žˆ๋Š” ์‚ฌ์šฉ์ž ๊ถŒํ•œ์„ ์คฌ๋Š”์ง€ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค. 

requestAuthorization

 

PHImageRequestOptions

ํฌํ†  ์—์…‹์œผ๋กœ ํ‘œํ˜„๋˜๋Š” ์Šคํ‹ธ ์ด๋ฏธ์ง€ ์ „์†ก์— ์˜ํ–ฅ์„ ๋ฏธ์น˜๋Š” ์˜ต์…˜ ์ง‘ํ•ฉ๋‹ˆ๋‹ค. image manager ๋กœ ๋ถ€ํ„ฐ ์š”์ฒญํ•˜์—ฌ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค.

์ด๋ฏธ์ง€์˜ ํ€„๋ฆฌํ‹ฐ๋ฅผ deliveryMode๋กœ ์ง€์ •ํ•  ์ˆ˜ ์žˆ๋‹ค. PHImageRequestOptionsDeliveryMode enum์„ ํฌํ•จํ•˜๊ณ  ์žˆ๋‹ค. ์ด๋ฏธ์ง€ ๋ฐ์ดํ„ฐ ์š”์ฒญ์— ๋Œ€ํ•œ ์˜ต์…˜์„ ์ง€์ •ํ•  ์ˆ˜ ์žˆ๋Š”๋ฐ ์—ฌ๊ธฐ์— deliveryMode ํ”„๋กœํผํ‹ฐ๊ฐ€ ์‚ฌ์šฉ๋œ๋‹ค. 

 

.opportunistic

์—ฌ๋Ÿฌ์žฅ์˜ ์‚ฌ์ง„์ด ์ž๋™์ ์œผ๋กœ ๋ฐธ๋Ÿฐ์Šค์™€ ํ€„๋ฆฌํ‹ฐ,  ๋ฐ˜์‘์„ฑ ์žˆ๋Š” ํ•œ๊ฐœ ์ด์ƒ์˜ ๊ฒฐ๊ณผ๋ฅผ ์ œ๊ณตํ•œ๋‹ค.

 

.highQualityFormat

์—ฌ๋Ÿฌ์žฅ์˜ ์‚ฌ์ง„์€ ์˜ค์ง ๊ณ ํ™”์งˆ์˜ ์ด๋ฏธ์ง€ ์ œ๊ณต๋งŒ์ด ๊ฐ€๋Šฅ. ๋‹ค๋งŒ ์ด ๊ธฐ๋Šฅ์€ ์–ผ๋งˆ๊ฐ„์— ์‹œ๊ฐ„์ด ๊ฑธ๋ฆฌ๋“  ์ƒ๊ด€์“ฐ์ง€ ์•Š๋Š”๋‹ค.

 

.fastFormat

์—ฌ๋Ÿฌ์žฅ์˜ ์‚ฌ์ง„์€ ์˜ค์ง ๋น ๋ฅธ ์†๋„์˜ ๋กœ๋”ฉ ์ด๋ฏธ์ง€๋ฅผ ์ œ๊ณตํ•œ๋‹ค. ์ด๋ฏธ์ง€์˜ ํ€„๋ฆฌํ‹ฐ๊ฐ€ ์ €ํ•˜๋  ์ˆ˜ ์žˆ๋‹ค.

 

 

--> ์ถ”๊ฐ€ : ๋น„๋””์˜ค ๊ด€๋ จ

AVAsset

๋น„๋””์˜ค๋ฅผ ํ•„์š”๋กœํ•˜๊ฑฐ๋‚˜ ์ˆ˜์ •ํ•˜๊ธฐ ์œ„ํ•ด์„œ ์—์…‹์„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค. 

 

AVPlayerItem

ํ”Œ๋ ˆ์ด๋ฐฑ(?)์„ ์œ„ํ•œ ๊ธฐ๋Šฅ ๊ตฌํ˜„์ด ํ•„์š”ํ•œ ๊ฒฝ์šฐ ์‚ฌ์šฉ

developer.apple.com/documentation/avfoundation/avplayeritem


์‚ฌ์šฉ์ž ๊ฐค๋Ÿฌ๋ฆฌ์— ์ ‘๊ทผํ•˜๊ธฐ ์œ„ํ•œ Privacy

 


์–ด๋–ป๊ฒŒ ์ด๋ฏธ์ง€๋ฅผ ๊ฐ€์ ธ ์˜ฌ ์ˆ˜ ์žˆ์„๊นŒ?

PHAsset์€ ๋ฉ”๋ชจ๋ฆฌ๋ฅผ ์ข€ ๋” ํšจ์œจ์ ์œผ๋กœ ๊ด€๋ฆฌํ•˜๊ธฐ ์œ„ํ•ด ๋Œ€๋Ÿ‰์˜ ์ •๋ณด๋ฅผ ๊ฐ€์ง€๊ณ  ์žˆ๋Š” ์ด๋ฏธ์ง€๋ฅผ ๊ทธ๋Œ€๋กœ ๊ฐ€์ ธ ์˜ค์ง€ ์•Š๊ณ  ์ด๋ฏธ์ง€์— ๋Œ€ํ•œ ์ •๋ณด๋ฅผ ๊ฐ€์ง€๊ณ  ์žˆ๋Š” ๋ฉ”ํƒ€ ๋ฐ์ดํ„ฐ๋ฅผ PHFetchResult ์ฝœ๋ ‰์…˜์— PHAsset์œผ๋กœ ๋‹ด์„ ์ˆ˜ ์žˆ๋‹ค. ๋”ฐ๋ผ์„œ ์ด๋ฏธ์ง€ ์ž์ฒด๊ฐ€ ์•„๋‹ˆ๋ฏ€๋กœ ์ด ๋ฉ”ํƒ€ ๋ฐ์ดํ„ฐ๋ฅผ ์‚ฌ์šฉํ•ด์„œ ์ด๋ฏธ์ง€๋ฅผ ๊ฐ€์ง€๊ณ  ์™€์•ผ ํ•œ๋‹ค. ์ด๋•Œ PHImageManager๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์ด๋ฏธ์ง€๋ฅผ ๋ฐ˜ํ™˜ ๋ฐ›์„ ์ˆ˜ ์žˆ๋‹ค. 

requestImage(for:targetSize:contentMode:options:resultHandler:)

 

asset

PHAsset.fetchAssets(with: nil) ๋“ฑ์„ ํ†ตํ•ด ๋ฐ˜ํ™˜ ๋ฐ›์€ PHFetchResult ์ฝœ๋ ‰์…˜์— ์žˆ๋Š” PHAsset ์ค‘ ๋กœ๋“œํ•ด์•ผ ํ•˜๋Š” ์ด๋ฏธ์ง€ ๋ฐ์ดํ„ฐ๋ฅผ ์„ ํƒํ•ด ์ค๋‹ˆ๋‹ค. PHFetchResult<PHAsset> ์—์„œ ํ•„์š”๋กœ ํ•˜๋Š” ์ด๋ฏธ์ง€ ๋ฐ์ดํ„ฐ๋ฅผ ์–ป๊ธฐ ์œ„ํ•ด ์ธ๋ฑ์Šค๋กœ ์ ‘๊ทผํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. 

 

targetSize

๋ฐ˜ํ™˜ ๋ฐ›์„ ์ด๋ฏธ์ง€์˜ ํฌ๊ธฐ๋ฅผ ๋‚˜ํƒ€๋ƒ…๋‹ˆ๋‹ค.

 

contentMode

๋ฆฌํ€˜์ŠคํŠธํ•œ ์ด๋ฏธ์ง€ ์‚ฌ์ด์ฆˆ๊ฐ€ ์–ด๋–ค ๋ชจ๋“œ๋กœ ๋ณด์—ฌ์•ผ ํ•  ์ง€ ์„ค์ •ํ•ด ์ค๋‹ˆ๋‹ค. PHImageContentMode์—๋Š” aspectFit, aspectFill์ด ์žˆ๊ณ  aspectFit์ด default๋กœ ์„ค์ •๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค. aspectFit์€ ์ด๋ฏธ์ง€ ์‚ฌ์ด์ฆˆ์— ๋งž์ถฐ์„œ ์ž˜๋ฆฌ์ง€ ์•Š๊ฒŒ ๋ฐฐ์น˜๋˜๊ณ  aspectFill์€ ์ด๋ฏธ์ง€๊ฐ€ ์ž˜๋ฆฌ๋”๋ผ๋„ ํ™”๋ฉด์— ๊ฝ‰ ์ฑ„์›Œ์ง€๊ฒŒ ๋ฉ๋‹ˆ๋‹ค.

๊ทธ๋Ÿฐ๋ฐ ๋ง์ž…๋‹ˆ๋‹ค,,, ๐Ÿง๐Ÿง

์™ผ์ชฝ์ด aspectFill ์˜ค๋ฅธ์ชฝ์ด aspectFit

์˜ˆ์ƒํ•œ ๊ฒƒ๊ณผ ๋‹ฌ๋ฆฌ ๋ฐ”๋€๊ฒŒ ์—†์–ด์„œ ๋šซ์–ด์ ธ๋ผ ๋ดค๋Š”๋ฐ ํ™”์งˆ์ด ๋‹ฌ๋ผ์ง‘๋‹ˆ๋‹ค. (์ •ํ™•ํžˆ ์•„์‹œ๋Š” ๋ถ„์˜ ์ œ๋ณด๋ฅผ ๊ธฐ๋‹ค๋ฆฝ๋‹ˆ๋‹ค..์˜ˆ..)

.aspectFit์€ ์ด๋ฏธ์ง€๋ฅผ ์ง€์ •ํ•œ ํƒ€๊ฒŸ์˜ ์‚ฌ์ด์ฆˆ์— ๋งž๋„๋ก ์ค„์ด๊ฒŒ ๋˜๊ณ  .aspectFill์€ ํƒ€๊ฒŸ ์‚ฌ์ด์ฆˆ์— ์™„์ „ํ•˜๊ฒŒ ์ฑ„์šฐ๋Š” ๋ฐฉ์‹์œผ๋กœ ์Šค์ผ€์ผ์„ ์ค„์ด๊ฒŒ ๋ฉ๋‹ˆ๋‹ค. 

 

scaleAspectFit

์˜ˆ์ƒํ–ˆ๋˜ aspectFit์€ ์œ„ ์‚ฌ์ง„๊ณผ ๊ฐ™์€๋ฐ ์กฐ๊ธˆ ๋‹ค๋ฅด๊ฒŒ ์ž‘๋™ํ•˜๋‚˜ ๋ด…๋‹ˆ๋‹ค. ์šฐ์„  scaleAspectFit์„ ์‚ฌ์šฉํ•˜๊ณ  ์‹ถ๋‹ค๋ฉด ์ด๋ฏธ์ง€ ๋ทฐ ์ž์ฒด์˜ contentMode๋กœ ์ง€์ •ํ•ด ์ฃผ์‹œ๋ฉด ์œ„์™€ ๊ฐ™์€ ๊ฒฐ๊ณผ๋ฅผ ์–ป์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค;; 

 

resultHandler

func requestImage(for asset: PHAsset, 
       targetSize: CGSize, 
      contentMode: PHImageContentMode, 
          options: PHImageRequestOptions?, 
    resultHandler: @escaping (UIImage?, [AnyHashable : Any]?) -> Void) -> PHImageRequestID

resultHandler๋ฅผ ํ†ตํ•ด ๋ฐ˜ํ™˜๋˜๋Š” ์ฒซ๋ฒˆ์งธ ์ธ์ž UIImage์— ์ด๋ฏธ์ง€๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ๋ฉ๋‹ˆ๋‹ค. ์‚ฌ์ด์ฆˆ์™€ ์˜ต์…˜, ์ปจํ…์ธ  ๋ชจ๋“œ๋ฅผ ์ง€์ •ํ•˜๊ณ  ํ•ด๋‹น ์กฐ๊ฑด์„ ๋งŒ์กฑํ•˜๋Š” ์ด๋ฏธ์ง€๋ฅผ ์–ป์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.


์›๋ณธ ์ด๋ฏธ์ง€๊ฐ€ ํ•„์š”ํ•œ ๊ฒฝ์šฐ

์ด์ฏค์—์„œ ์ƒ๊ธฐ๋Š” ์˜๋ฌธ! ์ด๋ฏธ์ง€ ์‚ฌ์ด์ฆˆ๋ฅผ ์…€์˜ ์‚ฌ์ด์ฆˆ ๋Œ€๋กœ ์ง€์ •ํ•ด ์ฃผ๊ธฐ ๋•Œ๋ฌธ์— ์›๋ณธ ์‚ฌ์ด์ฆˆ ๋ณด๋‹ค ๋” ์ž‘๊ฑฐ๋‚˜ ํฐ ์‚ฌ์ด์ฆˆ๋ฅผ ๊ฐ€์ง€๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค (๋Œ€๋ถ€๋ถ„ ๋” ์ž‘์€ ์‚ฌ์ด์ฆˆ). ์ด๋ฏธ์ง€์˜ ์‚ฌ์ด์ฆˆ๋Š” ์Šค์ผ€์ผ ๋Œ€๋กœ ๋ณ€๊ฒฝ๋˜์–ด ์žˆ๊ณ  ์›๋ณธ์˜ ํ™”์งˆ์ด ์•„๋‹ˆ๊ธฐ ๋•Œ๋ฌธ์— ์›๋ณธ์˜ ์ด๋ฏธ์ง€๊ฐ€ ํ•„์š”ํ•˜๊ฑฐ๋‚˜ ์ €์žฅํ•ด์•ผ ํ•˜๋Š” ๊ฒฝ์šฐ targetSize๋กœ ์ง€์ •ํ•˜์—ฌ ์–ป์–ด์˜จ ์ด๋ฏธ์ง€๋ฅผ ๊ทธ๋Œ€๋กœ ์‚ฌ์šฉํ•  ์ˆ˜๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค. 

 

์œ„์—์„œ PHImageRequestOptions๋ฅผ ๋ด…์‹œ๋‹ค. ์—ฌ๊ธฐ์— deliveryMode๋ฅผ ์ง€์ •ํ•˜์—ฌ ๊ณ ํ€„๋ฆฌํ‹ฐ์˜ ์‚ฌ์ง„์„ ๊ฐ€์ ธ ์˜ฌ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๊ทธ๋Ÿฌ๋‚˜ ์ ํ˜€ ์žˆ๋“ฏ์ด ๋‹ค๋ฅธ ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ•ฉ๋‹ˆ๋‹ค. ํ€„๋ฆฌํ‹ฐ๊ฐ€ ๋†’์€ ์‚ฌ์ง„์„ ๊ฐ€์ ธ์˜ค๊ธฐ ๋•Œ๋ฌธ์— ์‹œ๊ฐ„์ด ๊ณ ๋ ค๋˜์ง€ ์•Š์œผ๋ฉฐ ์˜ค๋ž˜ ๊ฑธ๋ฆฝ๋‹ˆ๋‹ค. ์‚ฌ์ง„ ๋กœ๋“œํ•˜๋Š” ์‹œ๊ฐ„์ด ๊ธธ๊ณ  ์‚ฌ์ง„์„ ๋กœ๋“œํ•˜๋Š”๋ฐ ๋งŽ์€ ๋ฉ”๋ชจ๋ฆฌ ์ž์›์„ ์‚ฌ์šฉํ•˜๊ธฐ ๋•Œ๋ฌธ์— ์›€์ง์ž„๋„ ์ž์—ฐ์Šค๋Ÿฝ์ง€ ์•Š๊ฒŒ ๋ฉ๋‹ˆ๋‹ค. 

 

๊ฐค๋Ÿฌ๋ฆฌ ์ž์ฒด์—๋‹ค๊ฐ€ ๋ณด์—ฌ์ง€๋Š” ์ด๋ฏธ์ง€๋Š” ์ธ๋„ค์ผ ์ด๋ฏธ์ง€๋ฅผ ํ™œ์šฉํ•ด์„œ ๋นจ๋ฆฌ ๋กœ๋“œํ•˜๋Š” ๊ฒƒ์ด ๋” ํšจ์œจ์ ์ด๋ฉฐ ์ด๋ฏธ์ง€๊ฐ€ ํ•„์š”ํ•œ ๊ฒฝ์šฐ ํ•ด๋‹น ์—์…‹์„ ์‚ฌ์šฉํ•ด์„œ ํ•„์š”ํ•œ ์ด๋ฏธ์ง€๋งŒ ๊ณ ํ€„๋ฆฌํ‹ฐ๋กœ ๋ฐ›๋Š”๊ฒŒ ์ข‹์Šต๋‹ˆ๋‹ค. 

 

        let requestImageOption = PHImageRequestOptions()
        requestImageOption.deliveryMode = PHImageRequestOptionsDeliveryMode.highQualityFormat

์›๋ณธ ์‚ฌ์ง„์˜ ๊ณ ํ€„๋ฆฌํ‹ฐ ์‚ฌ์ง„์„ ๊ฐ€์ ธ์˜ค๊ธฐ ์œ„ํ•ด deliveryMode๋ฅผ highqualityFormat ์œผ๋กœ ์ง€์ •ํ•ด ์ค๋‹ˆ๋‹ค. 

 

requestImageOption.deliveryMode = PHImageRequestOptionsDeliveryMode.highQualityFormat ๋Š” ๋ฌผ๋ก 

requestImageOption.deliveryMode = .highQualityFormat์ด๋ ‡๊ฒŒ ์ž‘์„ฑํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค (์Šค์œ„ํ”„ํŠธ ์ข‹๋‹ค. ๋„ˆ๋ฌด ๐Ÿค—)

let imageManager = PHImageManager()
imageManager.requestImage(for: asset, 
                          targetSize: PHImageManagerMaximumSize, 
                          contentMode: PHImageContentMode.default, 
                          options: requestImageOption) { (image, info) in

}

์˜ต์…˜์„ ์œ„์™€ ๊ฐ™์ด ์ง€์ •ํ•ด ์ค๋‹ˆ๋‹ค. ์—ฌ๊ธฐ์„œ contentMode ๋Š” default๋กœ ์ง€์ •๋˜์–ด ์žˆ์œผ๋‚˜ ํ•„์š”ํ•œ ๋ชจ๋“œ๋ฅผ ์„ ํƒํ•ด ์ค๋‹ˆ๋‹ค. 

PHImageManagerMaximumSize๋Š” PHImageManager์˜ ์ „์—ญ ๋ณ€์ˆ˜๋กœ์„œ ์›๋ณธ ์ด๋ฏธ์ง€ ๋ฐ์ดํ„ฐ์˜ ๋ฆฌํ€˜์ŠคํŠธ๋‚˜ ๊ฐ€์žฅ ์ตœ๋Œ€๋กœ ๋ Œ๋”๋ง ๋œ ์ด๋ฏธ์ง€๊ฐ€ ๊ฐ€๋Šฅํ•˜๊ฒŒ ํ•ด์ค๋‹ˆ๋‹ค. 


์ฐธ๊ณ  ์‚ฌ์ดํŠธ

 

 

How to get Original Image and media type from PHAsset?

My **GMImagePickerController** returns the list of selected images from photos app. The code are as follows. - (void)assetsPickerController:(GMImagePickerController *)picker didFinishPickingAs...

stackoverflow.com

 

Swiftly over the PhotoKit (1)

Most of the apps nowadays require work with photos and videos and Apple made an amazing framework to help us, developersโ€Š—โ€ŠPhotoKit.

medium.com

์ด์ƒํ•˜๊ฑฐ๋‚˜ ์ž˜๋ชป๋œ ๋‚ด์šฉ์ด ์žˆ์„์‹œ ๋Œ“๊ธ€ ๋ถ€ํƒ๋“œ๋ฆฝ๋‹ˆ๋‹ค

 

 

728x90
๋ฐ˜์‘ํ˜•

๋Œ“๊ธ€