2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

RubyMotionでAviaryを使って画像編集機能を簡単に追加する

Last updated at Posted at 2014-08-29

ソフトにちょっと画像編集機能を入れたい時にAviarySDKがあります。以下のような感じで簡単に編集機能を追加する事ができます。

sample.jpg

基本は無料のフリーミアムモデルです。編集後のサイズが1Mピクセル以上の出力がほしい場合は$120/月、Aviaryのリンクをはずしたい場合は$275/月が必要です。参照

編集機能を外部サービスに依存するのはサービス停止等のリスクを考えるとメインに使うには怖いんですが個人や趣味アプリ系なら良いかと。簡単に使える画像編集のSDKは少なくおもしろいビジネスモデルだと思いますので発展していって欲しいです。

手順

1.ファイルダウンロード

デベロッパー登録をしてSDKをダウンロードします。

2.アプリケーション登録

MyAppsからアプリケーション登録をすると、keyとsecretが表示されます。このキーをSDKで使います。

3.ファイル配置

下記の位置にSDKのファイルをコピー

vender/AviarySDK.framework
resources/AviarySDKResources.bunlde

4.Rakefile

Rakefile
Motion::Project::App.setup do |app|

	...(省略)...

  app.vendor_project('vendor/AviarySDK.framework',:static,
    :products => ['AviarySDK'],:headers_dir => 'Headers',
    :cflags => '-ObjC -all_load -fobjc-arc'
  )
  app.frameworks += %w(Accelerate Accelerate Foundation MessageUI
    OpenGLES QuartzCore StoreKit UIKit)
  app.libs += %w(/usr/lib/libsqlite3.0.dylib /usr/lib/libz.1.2.5.dylib)

end

5.実行はAPIキーをセットした後、画像を渡します

    AFPhotoEditorController.setAPIKey('***', secret:'***')
    editorController = AFPhotoEditorController.alloc.initWithImage(image)
    editorController.delegate = self
    presentViewController(editorController, animated:true, completion:nil)

delegateとして以下をセットします。

  def photoEditor(editor, finishedWithImage:image)
	# 編集済みimageをセット
    dismissViewControllerAnimated(true, completion:nil)
  end

  def photoEditorCanceled(editor)
	# キャンセル処理
    dismissViewControllerAnimated(true, completion:nil)
  end

サンプルコード

以下よりダウンロード可能です。

ぶつぶつ

  • FPhotoEditorCustomization.setToolOrderが実行できません。REPLで見てもmethodが変換されていないようです。Swiftから使ってみるとちゃんと使えるので、Framework側では無いようなのですが....
2
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?