The cat said

I am making a social APP recently, which needs an editor for pictures and videos, if you have the same needs as me

You can try img.ly

The original

Promise-amadi.medium.com/how-to-buil…

The source code

Github.com/Wizpna/phot…

reference

  • img.ly/photo-sdk
  • Pub. Dev/packages/ph…
  • Pub. Dev/packages/im…

The body of the

Hello everyone, in today’s article you will learn how to build a photo editing application using Flutter and img. ly.

However, before I dive into the technical aspects of this tutorial, I want to make a brief explanation of img.ly.

Img. LY is a Germany-based company that provides state-of-the-art image and video processing solutions through its Image and video editing SDK.

It is mainly used for photo editing purposes, and the SDK is easy to implement on mobile applications.

So let’s get started

Create a new Flutter project using Visual Studio, IntelliJ, or Android Studio.

After successfully creating a new FLUTTER project, open “pubspec.yaml” and install the photo_Editor_SDK and image_picker plug-ins.

dependencies:
  photo_editor_sdk: ^2.0. 0
  image_picker: ^0.81.+3
Copy the code

Note: The image_picker plug-in will be used to get photos from the device, while the photo_Editor_SDK will be used for photo editing.

Configure the PhotoEditor SDK for Android

The SDK is quite large, so you need to enable Multidex for your project as follows:

  1. The editorandroid/build.gradleAdd the following line at the top
buildscript {
    repositories {
        google()
        jcenter()
        maven { url "https://artifactory.img.ly/artifactory/imgly" }
    }
    dependencies {
        classpath 'com. Android. Tools. Build: gradle: 4.1.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath 'ly. Img. The android SDK: the plugin: 8.3.1'}}Copy the code

Note: To update the Android version of the PhotoEditor SDK, replace the version string version 8.3.1 with newer version newer Release.

  1. Open the**android/app/build.gradle** file (not android/build.gradle) and add the following line at the end:
android {
  defaultConfig {
      applicationId "com.example.photo_editor" minSdkVersion 16
      targetSdkVersion 30
      versionCode flutterVersionCode.toInteger()
      versionName flutterVersionName
      multiDexEnabled true
  }
}
dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'androidx. Multidex: multidex: 2.0.1'
}
Copy the code
  1. Open theandroid/app/build.gradle file (not android/build.gradleAdd the following line under the Apply Pluginapply plugin: "com.android.application":
apply plugin: 'ly.img.android.sdk'
apply plugin: 'kotlin-android'

apply plugin: 'ly.img.android.sdk'apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"// Comment out the modules you don't need, to save size.
imglyConfig {
    modules {
        include 'ui:text'
        include 'ui:focus'
        include 'ui:frame'
        include 'ui:brush'
        include 'ui:filter'
        include 'ui:sticker'
        include 'ui:overlay'
        include 'ui:transform'
        include 'ui:adjustment'
        include 'ui:text-design'// This module is big, remove the serializer if you don't need that feature.
        include 'backend:serializer'// Remove the asset packs you don't need, these are also big in size.
        include 'assets:font-basic'
        include 'assets:frame-basic'
        include 'assets:filter-basic'
        include 'assets:overlay-basic'
        include 'assets:sticker-shapes'
        include 'assets:sticker-emoticons'include 'backend:sticker-smart'}}Copy the code

Set up ImagePicker for iOS

Open /ios/Runner/ info.plist and add the following keys to the info.plist file

<key>NSPhotoLibraryUsageDescription</key>
           <string>app needs permission for the photo library</string>
           <key>NSCameraUsageDescription</key>
           <string>app needs access to the camera.</string>
           <key>NSMicrophoneUsageDescription</key>
           <string>app needs access to the microphone, if you intend to record videos.</string>
Copy the code

Open your main.dart file and update your code as shown in the following code snippet:

You must create a method called imgFromGallery

When the imgFromGallery method is called, it opens the image directory on the device.

The next step is to create another method called imglyEditor.

When the imglyEditor method is called, it opens the img. ly editor.

Run the application using a physical device or emulator test.

P.S: This is the source code


The elder brother of the © cat

  • ducafecat.tech/

  • github.com/ducafecat

  • Ducafecat WeChat group

  • B station space.bilibili.com/404904528

The issue of

Open source

GetX Quick Start

Github.com/ducafecat/g…

News client

Github.com/ducafecat/f…

Strapi manual translation

getstrapi.cn

Wechat discussion group Ducafecat

A series of collections

The translation

Ducafecat. Tech/categories /…

The open source project

Ducafecat. Tech/categories /…

Dart programming language basics

Space.bilibili.com/404904528/c…

Start Flutter with zero basics

Space.bilibili.com/404904528/c…

Flutter combat news client from scratch

Space.bilibili.com/404904528/c…

Flutter component development

Space.bilibili.com/404904528/c…

Flutter Bloc

Space.bilibili.com/404904528/c…

Flutter Getx4

Space.bilibili.com/404904528/c…

Docker Yapi

Space.bilibili.com/404904528/c…