Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Live PhotoをアニメーションGIFに書き出す
Search
Kei Ito
March 30, 2016
Technology
1.4k
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Live PhotoをアニメーションGIFに書き出す
関西モバイルアプリ研究会 #12 の資料です
http://kanmoba.connpass.com/event/28411/
Kei Ito
March 30, 2016
More Decks by Kei Ito
See All by Kei Ito
20211015 Mac CatalystでmacOS用アプリを作る
itok
2
4.5k
20210219 Flutterに入門してみた
itok
1
4.1k
20201009 iOS 14 ウィジェットをつくってみた
itok
1
2.5k
20191206 Property Wrappers 入門
itok
0
1.7k
20190920 iOS 13 対応ではまった話
itok
1
2.5k
20190726 Background App Refresh Taskがやってきた
itok
0
2.3k
20190722 Firebase Remote Configでアドネットワークを管理する
itok
0
1.6k
20190419 iOSアプリで証明書の情報を参照する
itok
0
1.5k
20190412 Android TV向けアプリを作ってみる
itok
0
1.1k
Other Decks in Technology
See All in Technology
LayerX コーポレートエンジニアリング室におけるサプライチェーンセキュリティへの取り組み / Supply Chain Security at LayerX Corporate Engineering
yuyatakeyama
2
680
SteampipeとExcel Power QueryでAWS構成定義書の作成を自動化する
jhashimoto
0
160
20260619 私の日常業務での生成 AI 活用
masaruogura
1
230
インシデントレスポンス演習 I / Incident Response Exercise I
ks91
PRO
0
100
2026TECHFRESH畢業分享會 - 葬送的通靈師:化系統與用戶雜訊成行動訊號
line_developers_tw
PRO
0
1.3k
Agile and AI Redmine Japan 2026
hiranabe
3
330
AIのReact習熟度を測る
uhyo
2
650
Oracle AI Database@Google Cloud:サービス概要のご紹介
oracle4engineer
PRO
6
1.5k
iAEONの段階的リアーキテクト戦略 / iAEON's_Gradual_Re-architecture_Strategy
aeonpeople
0
230
生成 AI 実践ガイド (概略版) AIガバナンス編
asei
0
130
GitHub Copilot app最速の発信の裏側
tomokusaba
1
190
Lightning近況報告
kozy4324
0
200
Featured
See All Featured
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
5
1.1k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.5k
Site-Speed That Sticks
csswizardry
13
1.2k
New Earth Scene 8
popppiees
3
2.3k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
19k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
55k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.3k
Optimising Largest Contentful Paint
csswizardry
37
3.7k
Context Engineering - Making Every Token Count
addyosmani
9
970
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.6k
Being A Developer After 40
akosma
91
590k
Scaling GitHub
holman
464
140k
Transcript
-JWF1IPUPΛ Ξχϝʔγϣϯ(*'ʹ ॻ͖ग़͢ ؔϞόΠϧΞϓϦݚڀձ !JUPL@UXJU
!JUPL@UXJU w ͍ͱ͏͚͍ʢJUPLʣ w ɹɹɹɹɹɹͷதͷਓ w ެࢲڞʹϓϩάϥϚJ04.BDʢͨ·ʹ"OESPJE8JOEPXTʣ w IUUQJUPLKQ IUUQTPSBLB[FDPKQ
ॴ USZTXJGU։࠵த
-JWF1IPUP͔ͬͯͭͬͯ·͢ʙʁ ڞ༗͢Δͷ͕େมͳΜͰ͢ΑͶʙ Ξχϝʔγϣϯ(*'ʹ͢ΔΞϓϦ ͋ΔΈ͍ͨͳΜͰ͚͢ͲͶ͑ʙ
͋ɺͦΕɺͰ͖·͢Α "7'PVOEBUJPOͱ͔*NBHF*0͑
ͬͯΈͨ
ΰʔϧ
ඞཁͳͷ w J04Ҏ্ w 1IPUPT w "7'PVOEBUJPO w *NBHF*0 w
J1IPOFTT1MVT4&J1BE1SPJODI
-JWF1IPUPΛ୳͢ // get all images let result = PHAsset.fetchAssetsWithMediaType(.Image, options:
nil) var photoAsset: PHAsset? result.enumerateObjectsUsingBlock { (obj, idx, stop) -> Void in let asset = obj as! PHAsset if asset.mediaSubtypes.contains(.PhotoLive) { photoAsset = asset stop.memory = true } })
-JWF1IPUPΛ୳͢ let mgr = PHImageManager.defaultManager() mgr.requestLivePhotoForAsset(photoAsset, targetSize: CGSizeZero, contentMode: .Default,
options: nil) { (livePhoto, info) -> Void in if let livePhoto = livePhoto { self.livePhotoView.livePhoto = livePhoto } }
ಈըΛऔΓग़͢ // search movie in live photo let resources =
PHAssetResource.assetResourcesForLivePhoto(photo) for resource in resources { if resource.type == .PairedVideo { self.getMovieData(resource) break } }
ಈըΛऔΓग़͢ // load movie data let mgr = PHAssetResourceManager.defaultManager() mgr.requestDataForAssetResource(resource,
options: nil, dataReceivedHandler: { (data) -> Void in movieData.appendData(data) }) { (err) -> Void in do { try movieData.writeToURL(movieURL, options:.AtomicWrite) let movieAsset = AVAsset(URL: movieURL) self.convertToGif(movieAsset, resource: resource) } catch { } }
ը૾ΛऔΓग़͢ // generate thumbnails and write to gif let generator
= AVAssetImageGenerator(asset: movieAsset) // generate in any timelines generator.requestedTimeToleranceBefore = kCMTimeZero generator.requestedTimeToleranceAfter = kCMTimeZero // apply video transform generator.appliesPreferredTrackTransform = true generator.maximumSize = CGSizeMake(640, 640) generator.generateCGImagesAsynchronouslyForTimes(times) { (requested, image, actual, result, err) -> Void in // }
"OJNBUJPO(*'ʹॻ͖ग़͢ let gif = CGImageDestinationCreateWithURL (gifURL, kUTTypeGIF, numFrame, nil) let
frameProperty = .. // AVAssetImageGenerator’s loop { CGImageDestinationAddImage(gif, image, frameProperty) } let gifProperty = .. CGImageDestinationSetProperties(gif, gifProperty) CGImageDestinationFinalize(gif) self.webView.loadRequest(NSURLRequest(URL: gifURL))
ίʔυͪ͜Βʹ HJUIVCDPNJUPL-JWF1IPUP5P"OJNBUFE(JG