iamutkarshtiwari/Ananas


An easy image editor integration for your Android apps.

Download


Step 1. Add the JitPack repository to your build file

Add it in your root settings.gradle at the end of repositories:

	dependencyResolutionManagement {
		repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
		repositories {
			mavenCentral()
			maven { url 'https://jitpack.io' }
		}
	}

Add it in your settings.gradle.kts at the end of repositories:

	dependencyResolutionManagement {
		repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
		repositories {
			mavenCentral()
			maven { url = uri("https://jitpack.io") }
		}
	}

Add to pom.xml

	<repositories>
		<repository>
		    <id>jitpack.io</id>
		    <url>https://jitpack.io</url>
		</repository>
	</repositories>

Add it in your build.sbt at the end of resolvers:

 
    resolvers += "jitpack" at "https://jitpack.io"
        
    

Add it in your project.clj at the end of repositories:

 
    :repositories [["jitpack" "https://jitpack.io"]]
        
    

Step 2. Add the dependency

	dependencies {
		implementation 'com.github.iamutkarshtiwari:ananas:1.2.6'
	}
	dependencies {
		implementation("com.github.iamutkarshtiwari:ananas:1.2.6")
	}
	<dependency>
	    <groupId>com.github.iamutkarshtiwari</groupId>
	    <artifactId>ananas</artifactId>
	    <version>1.2.6</version>
	</dependency>

                            
    libraryDependencies += "com.github.iamutkarshtiwari" % "ananas" % "1.2.6"
        
        

                            
    :dependencies [[com.github.iamutkarshtiwari/ananas "1.2.6"]]
        
        

Readme


<img align="left" src="art/ananas.png" width="100" height="100" />

Ananas Photo Editor

Download API

An easy photo editor integration for your Android apps.

Features

Benefits

  • Plug and play
  • Easy image editing
<br>

Previews

Main Menu | Text Mode :--: | :--: <img src="/static/main_menu.gif" width="300" /> | <img src="/static/text_mode.gif" width="300" />

Rotate Mode | Crop Mode :--: | :--: <img src="/static/rotate_mode.gif" width="300" /> | <img src="/static/crop_feature.gif" width="300" />

Filter Mode | Paint Mode :--: | :--: <img src="/static/filter_mode.gif" width="300" /> | <img src="/static/paint_mode.gif" width="300" />

Beauty Mode | Saturation Mode :--: | :--: <img src="/static/beauty_mode.gif" width="300" /> | <img src="/static/saturation_mode.gif" width="300" />

Brightness Mode | Sticker Mode :--: | :--: <img src="/static/brightness_mode.gif" width="300" /> | <img src="/static/sticker_mode.gif" width="300" />

<br>

Getting Started

Add it in your root build.gradle at the end of repositories:

  allprojects {
    repositories {
      ...
      maven { url 'https://jitpack.io' }
    }
  }

Add the dependency in gradle file of app module like this

implementation 'com.github.iamutkarshtiwari:Ananas:1.2.6'

[Important!]

Add this to your app's proguard-rules.pro file:

-keepclasseswithmembers class * {
    native <methods>;
}

And this to your app's build.gradle:

compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
}

NOTE:

Since this library uses RxJava 2.0 and if your project uses RxJava 1.0, then you need to add the below code to the gradle file of you app so that both versions can co-exist-

android {
    packagingOptions {
        exclude 'META-INF/rxjava.properties'
    }
}

Starting the PhotoEditor activity

Add this constant to your activity class with your preferred request code:

private final int PHOTO_EDITOR_REQUEST_CODE = 231;// Any integer value as a request code.

Use the following code to build and launch the photo editor:


 try {
  Intent intent = new ImageEditorIntentBuilder(this, sourceImagePath, outputFilePath)
         .withAddText() // Add the features you need
         .withPaintFeature()
         .withFilterFeature()
         .withRotateFeature()
         .withCropFeature()
         .withBrightnessFeature()
         .withSaturationFeature()
         .withBeautyFeature()
         .withStickerFeature()
         .forcePortrait(true)  // Add this to force portrait mode (It's set to false by default)
         .setSupportActionBarVisibility(false) // To hide app's default action bar
         .build();

 EditImageActivity.start(activity, intent, PHOTO_EDITOR_REQUEST_CODE);
 } catch (Exception e) {
     Log.e("Demo App", e.getMessage()); // This could throw if either `sourcePath` or `outputPath` is blank or Null
 }

Receiving the output image

You can receive the new processed image path and it's edit status like this-

 @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);

        if (requestCode == PHOTO_EDITOR_REQUEST_CODE) { // same code you used while starting
            String newFilePath = data.getStringExtra(ImageEditorIntentBuilder.OUTPUT_PATH);
            boolean isImageEdit = data.getBooleanExtra(EditImageActivity.IS_IMAGE_EDITED, false);
        }
    }

Special Note

The photo editor locks the current orientation in which it is started - 1) If you started in Portrait mode, you can't switch to Landscape while the image editor activity is running. 2) If you started in Landscape mode, you can't switch to Portrait during the same.

But once you navigate back to your original app, you are reverted back to your previous configuration change settings.

How to contribute?

  • Fork the project.
  • Make required changes and commit.
  • Generate pull request. Mention all the required description regarding changes you made.

Happy coding! :)

What's next?

  • Add support for configuration change during photo editing

Questions?🤔

Hit me on twitter Twitter Facebook

How to submit a valid issue

  • Make sure you compiled the latest version. If it still doesn't work out, don't hesitate to open a new issue.
  • Describe the scenarios when crash happened as much as possible (pictures would be better).
  • Sharing your device type and Android OS version is very helpful.
  • Paste your XML or Java code.
  • Paste the crash log.
  • Be polite.

Credits

Name | Library ------------ | ------------- siwangqishiq | ImageEditor Android ArthurHub | Android Image Cropper hoanganhtuan95ptit | Contrast and Brightness feature eltos | Color Picker Dialog Russell Jurney | Kelly's 22 colors list burhanrashid52 | PhotoEditor