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
Image uploading on iOS
Search
cockscomb
May 21, 2015
Programming
0
1.7k
Image uploading on iOS
Presented at 関西モバイルアプリ研究会 #2
cockscomb
May 21, 2015
Tweet
Share
More Decks by cockscomb
See All by cockscomb
jq at the Shortcuts
cockscomb
1
1.7k
GraphQL放談
cockscomb
4
1.9k
GraphQL Highway
cockscomb
28
8.2k
吉田を支える技術
cockscomb
0
2.1k
コーポレートサイトを静的化してAmplify Consoleにデプロイする
cockscomb
0
3.3k
ユーザインターフェイスと非同期処理
cockscomb
5
1.8k
GUIアプリケーションの構造と設計
cockscomb
10
10k
イカリング2におけるシングルページアプリケーション
cockscomb
2
7.4k
あなたの知らない UIKit の世界 — UITableView に UITextView を置きたい
cockscomb
1
7.3k
Other Decks in Programming
See All in Programming
Jakarta EE meets AI
ivargrimstad
0
130
Click-free releases & the making of a CLI app
oheyadam
2
110
광고 소재 심사 과정에 AI를 도입하여 광고 서비스 생산성 향상시키기
kakao
PRO
0
170
CSC509 Lecture 09
javiergs
PRO
0
140
Jakarta EE meets AI
ivargrimstad
0
600
C++でシェーダを書く
fadis
6
4.1k
NSOutlineView何もわからん:( 前編 / I Don't Understand About NSOutlineView :( Pt. 1
usagimaru
0
330
Jakarta Concurrencyによる並行処理プログラミングの始め方 (JJUG CCC 2024 Fall)
tnagao7
1
290
シェーダーで魅せるMapLibreの動的ラスタータイル
satoshi7190
1
480
Nurturing OpenJDK distribution: Eclipse Temurin Success History and plan
ivargrimstad
0
880
聞き手から登壇者へ: RubyKaigi2024 LTでの初挑戦が 教えてくれた、可能性の星
mikik0
1
130
Tauriでネイティブアプリを作りたい
tsucchinoko
0
370
Featured
See All Featured
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
329
21k
The Cost Of JavaScript in 2023
addyosmani
45
6.7k
How to Think Like a Performance Engineer
csswizardry
20
1.1k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
169
50k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
38
1.8k
Teambox: Starting and Learning
jrom
133
8.8k
Measuring & Analyzing Core Web Vitals
bluesmoon
4
120
Navigating Team Friction
lara
183
14k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
28
2k
Intergalactic Javascript Robots from Outer Space
tanoku
269
27k
Building a Scalable Design System with Sketch
lauravandoore
459
33k
Thoughts on Productivity
jonyablonski
67
4.3k
Transcript
iOSͰͷ ը૾Ξοϓϩʔυ
cockscomb
None
iOSͰͷ ը૾Ξοϓϩʔυ
ԿΛ͍·͞Β w J04ͷਐԽʹͬͯ࠷৽ͷख๏Λհ͍ͨ͠ w ϕετϓϥΫςΟεͰ͢
ը૾Ξοϓϩʔυͷखॱ 1IPUP-JCSBSZ͔ΒσʔλΛऔಘ ը૾ͷՃ ਖ਼͍͖͠ʹճస ඞཁͳαΠζʹॖখ
దͳܗࣜʹѹॖ Ξοϓϩʔυ
σʔλΛऔಘ • UIImagePickerController • UIImagePickerControllerOriginalImage • UIImagePickerControllerEditedImage • AssetsLibrary •
Photos
σʔλΛऔಘ let asset: PHAsset var originalData: NSData? var type: UTI?
var imageOrientation: UIImageOrientation = .Up let options = PHImageRequestOptions() options.synchronous = true options.version = .Current let imageManager = PHImageManager.defaultManager() imageManager.requestImageDataForAsset(asset, options: options) { (imageData, dataUTI, orientation, info) -> Void in originalData = imageData type = UTI(dataUTI) imageOrientation = orientation }
ը૾ͷՃ w 6*,JU w $PSF(SBQIJDT w $PSF*NBHF
ਖ਼͍͖͠ʹճస var image = CIImage(CGImage: originalImage) // See: kCGImagePropertyOrientation var
orientationValue: Int32 = 1 switch orientation { case .Up: break case .Down: orientationValue = 3 case .Left: orientationValue = 8 case .Right: orientationValue = 6 ... } image = image.imageByApplyingOrientation(orientationValue)
ඞཁͳαΠζʹॖখ var image: CIImage let scale: CGFloat = 0.5 let
lanczosResamplingFilter = CIFilter( name: "CILanczosScaleTransform", withInputParameters: [ "inputImage" : image, "inputScale" : scale, ]) image = lanczosResamplingFilter.outputImage
దͳܗࣜʹѹॖ let context = CIContext(options: [:]) let scaledImage = context.createCGImage(image,
fromRect: image.extent()) let processedData = NSMutableData() let destination = CGImageDestinationCreateWithData( processedData, type.UTIString, 1, nil) CGImageDestinationAddImage(destination, scaledImage, [ kCGImageDestinationLossyCompressionQuality as String : 0.8, ] as [ String : AnyObject ]) CGImageDestinationFinalize(destination)
Ξοϓϩʔυ w ϚϧνύʔτϦΫΤετͱ͔Ͱ w ͦΕͧΕ͕ΜΔ
ը૾Ξοϓϩʔυͷखॱ 1IPUP-JCSBSZ͔ΒσʔλΛऔಘ ը૾ͷՃ ਖ਼͍͖͠ʹճస ඞཁͳαΠζʹॖখ
దͳܗࣜʹѹॖ Ξοϓϩʔυ
ิ w શମΛNSOperationͷαϒΫϥεͳͲͰ࡞Δͱ Α͍ w $PSF*NBHFΛ͏ͱ͖ɺՄೳͳΒCIContext ͍ճ͢ͱΑ͍
iOSͰͷ ը૾Ξοϓϩʔυ