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.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.3k
Other Decks in Programming
See All in Programming
たのしいparse.y
ydah
3
120
アクターシステムに頼らずEvent Sourcingする方法について
j5ik2o
4
210
Scalaから始めるOpenFeature入門 / Scalaわいわい勉強会 #4
arthur1
1
300
DevFest Tokyo 2025 - Flutter のアプリアーキテクチャ現在地点
wasabeef
5
900
わたしの星のままで一番星になる ~ 出産を機にSIerからEC事業会社に転職した話 ~
kimura_m_29
0
180
RWC 2024 DICOM & ISO/IEC 2022
m_seki
0
210
[JAWS-UG横浜 #76] イケてるアップデートを宇宙いち早く紹介するよ!
maroon1st
0
450
14 Years of iOS: Lessons and Key Points
seyfoyun
1
770
StarlingMonkeyを触ってみた話 - 2024冬
syumai
3
270
ブラウザ単体でmp4書き出すまで - muddy-web - 2024-12
yue4u
2
460
Go の GC の不得意な部分を克服したい
taiyow
2
770
Refactor your code - refactor yourself
xosofox
1
260
Featured
See All Featured
Typedesign – Prime Four
hannesfritz
40
2.4k
Bootstrapping a Software Product
garrettdimon
PRO
305
110k
Docker and Python
trallard
42
3.1k
Testing 201, or: Great Expectations
jmmastey
40
7.1k
A Tale of Four Properties
chriscoyier
157
23k
How to train your dragon (web standard)
notwaldorf
88
5.7k
Code Reviewing Like a Champion
maltzj
520
39k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
507
140k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
38
1.9k
Automating Front-end Workflow
addyosmani
1366
200k
How to Think Like a Performance Engineer
csswizardry
22
1.2k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
28
4.4k
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Ͱͷ ը૾Ξοϓϩʔυ