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.8k
GraphQL放談
cockscomb
4
1.9k
GraphQL Highway
cockscomb
28
8.3k
吉田を支える技術
cockscomb
0
2.2k
コーポレートサイトを静的化してAmplify Consoleにデプロイする
cockscomb
0
3.4k
ユーザインターフェイスと非同期処理
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
Bedrock Agentsレスポンス解析によるAgentのOps
licux
3
840
Amazon S3 TablesとAmazon S3 Metadataを触ってみた / 20250201-jawsug-tochigi-s3tables-s3metadata
kasacchiful
0
160
2,500万ユーザーを支えるSREチームの6年間のスクラムのカイゼン
honmarkhunt
6
5.3k
パスキーのすべて ── 導入・UX設計・実装の紹介 / 20250213 パスキー開発者の集い
kuralab
3
780
時計仕掛けのCompose
mkeeda
1
300
データの整合性を保つ非同期処理アーキテクチャパターン / Async Architecture Patterns
mokuo
47
17k
Spring gRPC について / About Spring gRPC
mackey0225
0
220
Kubernetes History Inspector(KHI)を触ってみた
bells17
0
230
メンテが命: PHPフレームワークのコンテナ化とアップグレード戦略
shunta27
0
120
Djangoアプリケーション 運用のリアル 〜問題発生から可視化、最適化への道〜 #pyconshizu
kashewnuts
1
250
ファインディの テックブログ爆誕までの軌跡
starfish719
2
1.1k
Immutable ActiveRecord
megane42
0
140
Featured
See All Featured
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
44
7k
How to Think Like a Performance Engineer
csswizardry
22
1.3k
Making the Leap to Tech Lead
cromwellryan
133
9.1k
[RailsConf 2023] Rails as a piece of cake
palkan
53
5.2k
Docker and Python
trallard
44
3.3k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
32
2.1k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
45
9.4k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
507
140k
The Power of CSS Pseudo Elements
geoffreycrofte
75
5.5k
Gamification - CAS2011
davidbonilla
80
5.1k
Building Adaptive Systems
keathley
40
2.4k
StorybookのUI Testing Handbookを読んだ
zakiyama
28
5.5k
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Ͱͷ ը૾Ξοϓϩʔυ