DS Photo Editor SDK

A Photo Editor Built for Developers

Getting started with DS Photo Editor SDK for Android

This guide will show you how to integrate DS Photo Editor SDK into your android apps, within just minutes!

Prerequisites

1. Download the SDK as an .aar file:

 

 

 

2. The following software is required:

  • Mac OS X, Windows, or Linux

  • Android Studio 3.0 or higher

  • Target android SDK 25 or higher

  • Minimum android SDK 18 or higher

  • Gradle 3.0 or higher

  • Android build tools version 25.0.0 or higher

  • Android Support Repository 25.0.0 or higher

Adding the SDK to a New Project

1. Copy downloaded "ds-photo-editor-sdk-v9.aar"  into your project's /libs directory. Create this directory if it doesn't already exist in your project.

IMPORTANT: If you already have the SDK integrated and you are trying to update the aar file in your /libs folder, please make sure that you click the "Sync Project with Gradle Files" button to re-sync your project after replacing the aar file.

2. Open the project-level build.gradle, and update the repositories section as below.

 

 allprojects {

      repositories {

          jcenter()

         google() // Google's Maven repository

         

         flatDir {

             dirs 'libs'

         }

      }

 }

2. Open the app level build.gradle file, and update defaultConfig and dependencies as below.

 android {

     ......

      compileSdkVersion 28

     buildToolsVersion "28.0.3"

     defaultConfig {

           minSdkVersion 18

         targetSdkVersion 28

         ......

         renderscriptTargetApi 21

         renderscriptSupportModeEnabled true

     }

     ......

 }

 dependencies {

     // DS Photo Editor SDK

     implementation fileTree(dir: 'libs', include: ['*.jar'])

     implementation(name:'ds-photo-editor-sdk-v9', ext:'aar')

    

     // SDK related dependencies

     implementation 'com.android.support:appcompat-v7:28.0.0'

     implementation 'com.squareup.picasso:picasso:2.71828'

     implementation 'io.reactivex.rxjava2:rxjava:2.1.0'

     implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'

 }

Update the AndroidManifest.xml file

Photo editing apps need more memories than normal apps, so make sure to set android:largeHeap to be true in your application declaration. Also update the manifest file to include the SDK activities and required permissions.

Please note: In order to save edited photo on android devices, you will need to request storage permissions at run time for Android 6.0+. An example is included in our Android sample code, and more info can be found here https://developer.android.com/training/permissions/requesting.html.

......

<uses-permission android:name="android.permission.INTERNET" />

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

<application

     ......

     android:largeHeap="true"

     >

     ......

     <activity

          android:name="com.dsphotoeditor.sdk.activity.DsPhotoEditorActivity"

          android:screenOrientation="portrait"

          android:theme="@android:style/Theme.Holo.NoActionBar" />

     <activity 

         android:name="com.dsphotoeditor.sdk.activity.DsPhotoEditorStickerActivity" 

         android:screenOrientation="portrait"

         android:theme="@android:style/Theme.Holo.NoActionBar" />

     <activity

         android:name="com.dsphotoeditor.sdk.activity.DsPhotoEditorTextActivity"

         android:screenOrientation="portrait"

         android:theme="@android:style/Theme.Holo.NoActionBar"

         android:windowSoftInputMode="adjustPan" />

     <activity

         android:name="com.dsphotoeditor.sdk.activity.DsPhotoEditorCropActivity" 

         android:screenOrientation="portrait"

         android:theme="@android:style/Theme.Holo.NoActionBar" />

     <activity

         android:name="com.dsphotoeditor.sdk.activity.DsPhotoEditorDrawActivity" 

         android:screenOrientation="portrait"

         android:theme="@android:style/Theme.Holo.NoActionBar" />

 </application>

Launch DS Photo Editor

With just a few lines of java code, you can launch the DS Photo Editor page with your specified image.

An image uri is required for the input image. An optional parameter can be provided to specify the directory to save the output image on device's external storage. If the output directory is omitted, the edited photo will be saved into a folder called "DS_Photo_Editor" by default.

You can also customize the tools in the SDK if you don't want some of the tools to show up. Just simply pass in the tools to hide in the UI.

     ......

     // If the input image uri for DS Photo Editor is "inputImageUri", launch the editor UI

     // using the following code

     Intent dsPhotoEditorIntent = new Intent(this, DsPhotoEditorActivity.class); 

     dsPhotoEditorIntent.setData(inputImageUri);

     // This is optional. By providing an output directory, the edited photo

     // will be saved in the specified folder on your device's external storage;

     // If this is omitted, the edited photo will be saved to a folder

     // named "DS_Photo_Editor" by default.

     dsPhotoEditorIntent.putExtra(DsPhotoEditorConstants.DS_PHOTO_EDITOR_OUTPUT_DIRECTORY, "YOUR_OUTPUT_IMAGE_FOLDER");

        // Optional customization: hide some tools you don't need as below

     int[] toolsToHide = {DsPhotoEditorActivity.TOOL_ORIENTATION, DsPhotoEditorActivity.TOOL_CROP};  

     dsPhotoEditorIntent.putExtra(DsPhotoEditorConstants.DS_PHOTO_EDITOR_TOOLS_TO_HIDE, toolsToHide);

     startActivityForResult(dsPhotoEditorIntent, 200);

Handle Activity Result from DS Photo Editor

The edited image will be returned to the calling activity as an image uri. You can handle the result as you want in the "onActivityResult" method as below.

 protected void onActivityResult(int requestCode, int resultCode, Intent data) {

     if (resultCode == RESULT_OK) {

         switch (requestCode) {

             case 200:

                 Uri outputUri = data.getData();

                 // handle the result uri as you want, such as display it in an imageView;

                 // imageView.setImageURI(outputUri);     

                 break;

         }

     }

 }

The edited photo will have the same size as input image, even though the input photo is an HD photo. However, on older devices with Android Kitkat and Jelly Bean, the output photo will have similar amount of pixels as the device screen, so that the performance of the photo editor can be smooth on older devices.

Photo editing consumes much more memory than other operations on mobile devices, so please make sure that you use a proper size for input images. If your app already uses a lot of memory before launching our photo editor, passing in an HD image could use up all the memory allocated to your app.

This is it! By following the simple steps above, you now have integrated the DS Photo Editor into your android apps!

DS Photo Editor SDK - iOS & Android

Terms Of Service

Privacy Policy