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.3k
吉田を支える技術
cockscomb
0
2.2k
コーポレートサイトを静的化して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.4k
Other Decks in Programming
See All in Programming
AWSのLambdaで PHPを動かす選択肢
rinchoku
2
390
週次リリースを実現するための グローバルアプリ開発
tera_ny
1
1.2k
ErdMap: Thinking about a map for Rails applications
makicamel
1
580
HTML/CSS超絶浅い説明
yuki0329
0
190
DevinとCursorから学ぶAIエージェントメモリーの設計とMoatの考え方
itarutomy
0
120
DMMオンラインサロンアプリのSwift化
hayatan
0
170
Fibonacci Function Gallery - Part 2
philipschwarz
PRO
0
210
Rubyでつくるパケットキャプチャツール
ydah
0
160
月刊 競技プログラミングをお仕事に役立てるには
terryu16
1
1.2k
ある日突然あなたが管理しているサーバーにDDoSが来たらどうなるでしょう?知ってるようで何も知らなかったDDoS攻撃と対策 #phpcon.2024
akase244
2
7.7k
Fixstars高速化コンテスト2024準優勝解法
eijirou
0
190
オニオンアーキテクチャを使って、 Unityと.NETでコードを共有する
soi013
0
370
Featured
See All Featured
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
8
1.2k
Building Better People: How to give real-time feedback that sticks.
wjessup
366
19k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
28
4.5k
Faster Mobile Websites
deanohume
305
30k
Mobile First: as difficult as doing things right
swwweet
222
9k
Bash Introduction
62gerente
610
210k
Bootstrapping a Software Product
garrettdimon
PRO
305
110k
A better future with KSS
kneath
238
17k
Build your cross-platform service in a week with App Engine
jlugia
229
18k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
132
33k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
356
29k
Designing Experiences People Love
moore
139
23k
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Ͱͷ ը૾Ξοϓϩʔυ