Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Live PhotoをアニメーションGIFに書き出す
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
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.6k
20191206 Property Wrappers 入門
itok
0
1.8k
20190920 iOS 13 対応ではまった話
itok
1
2.6k
20190726 Background App Refresh Taskがやってきた
itok
0
2.4k
20190722 Firebase Remote Configでアドネットワークを管理する
itok
0
1.7k
20190419 iOSアプリで証明書の情報を参照する
itok
0
1.6k
20190412 Android TV向けアプリを作ってみる
itok
0
1.2k
Other Decks in Technology
See All in Technology
OptunaHub: ブラックボックス最適化のためのプラットフォーム
pfn
PRO
0
140
20261017福岡devIO 「AIは"良いダッシュボード"を作れるか?
jtakeda
0
180
DevelopersIO 2026 知識の地図を描く ─ オントロジーとは何か?
ishikawa_satoru
1
1.7k
Metadata - Section 1: HTML Basics
mohab1
0
120
Claude の新機能を、 出た日に触って社内に届けるまで
rfdnxbro
1
190
[JAWS-UG彩の国埼玉#12]そろそろ準備する?re:Invent2026をやさしく解説 / reinvent2026-sainokuni
sh_fk2
1
350
PHPカンファレンス関西の招待状 / Invitation to PHP Conference Kansai
ykanoh
0
200
LambdaWebFunctionsを試してみた / exploring-lambda-web-functions
koukihosaka
1
360
Refining Active Record
shugo
0
160
専門領域のAIをどう評価するか
bengo4com
2
280
WasmをRustにする
sansantech
PRO
0
260
日本語に強いオープンな大規模言語モデル「LLM-jp」
odashi
5
1.2k
Featured
See All Featured
AI Search: Implications for SEO and How to Move Forward - #ShenzhenSEOConference
aleyda
1
1.4k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
3.1k
職位にかかわらず全員がリーダーシップを発揮するチーム作り / Building a team where everyone can demonstrate leadership regardless of position
madoxten
69
67k
How to Think Like a Performance Engineer
csswizardry
28
2.9k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.9k
Intergalactic Javascript Robots from Outer Space
tanoku
273
28k
More Than Pixels: Becoming A User Experience Designer
marktimemedia
3
570
The Anti-SEO Checklist Checklist. Pubcon Cyber Week
ryanjones
0
270
The Mindset for Success: Future Career Progression
greggifford
PRO
0
540
Large-scale JavaScript Application Architecture
addyosmani
516
110k
The #1 spot is gone: here's how to win anyway
tamaranovitovic
4
1.2k
The Power of CSS Pseudo Elements
geoffreycrofte
82
6.6k
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