Git Product home page Git Product logo

ananas's Introduction

Ananas Photo Editor

Download API

An easy photo editor integration for your Android apps.

Features

Benefits

  • Plug and play
  • Easy image editing

Previews

Main Menu Text Mode
Rotate Mode Crop Mode
Filter Mode Paint Mode
Beauty Mode Saturation Mode
Brightness Mode Sticker Mode

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

ananas's People

Contributors

dhananjaym2 avatar iamutkarshtiwari avatar mostafaimran avatar ramachandrajoshi avatar salvadorangel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ananas's Issues

Failed to load the image!

First of all, Your library is very helpful to me.
But now when i pass filePath to EditImageActivity i always this error "Failed to load the image!"

You have used this Toast in this method given below.

Have you updated the code ?
Can you help me in this ?

private void loadImageFromFile(String filePath) {
        compositeDisposable.clear();

        Disposable loadImageDisposable = loadImage(filePath)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .doOnSubscribe(subscriber -> loadingDialog.show())
                .doFinally(() -> loadingDialog.dismiss())
                .subscribe(processedBitmap -> changeMainBitmap(processedBitmap, false), e -> showToast(R.string.iamutkarshtiwari_github_io_ananas_load_error));

        compositeDisposable.add(loadImageDisposable);
    }

--

Thanks & Regards,
Yatin Julka
Android Developer

NullPointer Exception

java.lang.NullPointerException: Attempt to write to field 'int iamutkarshtiwari.github.io.ananas.editimage.EditImageActivity.mode' on a null object reference
at iamutkarshtiwari.github.io.ananas.editimage.fragment.StickerFragment.onShow(StickerFragment.java:104)
at iamutkarshtiwari.github.io.ananas.editimage.fragment.MainMenuFragment.onStickClick(MainMenuFragment.java:145)
at iamutkarshtiwari.github.io.ananas.editimage.fragment.MainMenuFragment.onClick(MainMenuFragment.java:123)
at android.view.View.performClick(View.java:6597)
at android.view.View.performClickInternal(View.java:6574)
at android.view.View.access$3100(View.java:778)
at android.view.View$PerformClick.run(View.java:25885)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at androidx.test.espresso.base.Interrogator.a(Interrogator.java:31)
at androidx.test.espresso.base.UiControllerImpl.a(UiControllerImpl.java:132)
at androidx.test.espresso.base.UiControllerImpl.a(UiControllerImpl.java:126)
at androidx.test.espresso.base.UiControllerImpl.a(UiControllerImpl.java:42)
at androidx.test.espresso.action.MotionEvents.a(MotionEvents.java:75)
at androidx.test.espresso.action.Tap.b(Tap.java:16)
at androidx.test.espresso.action.Tap$1.a(Tap.java:2)
at androidx.test.espresso.action.GeneralClickAction.perform(GeneralClickAction.java:11)
at androidx.test.espresso.ViewInteraction$SingleExecutionViewAction.perform(ViewInteraction.java:8)
at androidx.test.espresso.ViewInteraction.a(ViewInteraction.java:33)
at androidx.test.espresso.ViewInteraction$1.call(ViewInteraction.java:2)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6718)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

When I was testing it on Pixel 2, API level 28.

Set the brush to lower size

I want to open the Editor and have the brush functionality but i want to use a lower size as a default. Is there any way to do this?

Failed to load the image!

Every time I selects image, I get failed to load the image!
I've tried many different ways but I didn't get what's the problem. I shared my code please check and let me know if there is any problem in implementation.

    try {
            Intent intent = new ImageEditorIntentBuilder(this, data.getData(), Environment.getExternalStorageDirectory().getAbsolutePath()+"/test.png")
                    .withAddText() // Add the features you need
                    .withFilterFeature()
                    .withRotateFeature()
                    .withCropFeature()
                    .withStickerFeature()
                    .forcePortrait(true)
                    .build();

            EditImageActivity.start((MainActivity) mContext, intent, PHOTO_EDITOR_REQUEST_CODE);
        } catch (Exception e) {
            Log.e(TAG, "onActivityResult: "+e.getMessage() );
        }

Improve seekbars

Improve seek bars in Rotate, Brightness, Saturation and Beautify fragments.

Add option for disable Default ActionBar

@iamutkarshtiwari
In my application the default theme has the default ActionBar of the android application that the Android studio provides.
So when i open the EditImageActivity its like i see two action bars. I want to keep your actionBar and hide mine. How can i do that?

109894721_3358278964236846_7973803831109147401_n

Failed To Load The Image! Android Q

Greetings,
The library is fabulously working till API 28 or Android Pie. But when I run it in Android Q or API 29(or above version). It fails to load the image. Then I decided to look upon the code and I saw the library using BitmapFactory.decodeFile which I think would be difficult to use as Android Q or 10 has curbed Storage Path for User privacy.
From my view, these functions are making trouble for Android 10

utils/BitmapUtils.java

For loading the image:
public static Bitmap getSampledBitmap(String filePath, int reqWidth, int reqHeight) { BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; options.inSampleSize = calculateInSampleSize(options, reqWidth, reqHeight); options.inPreferredConfig = Bitmap.Config.RGB_565; options.inJustDecodeBounds = false; return BitmapFactory.decodeFile(filePath, options); }
For saving the image
public static boolean saveBitmap(Bitmap bm, String filePath) { File f = new File(filePath); if (f.exists()) { f.delete(); } try { FileOutputStream out = new FileOutputStream(f); bm.compress(Bitmap.CompressFormat.PNG, 90, out); out.flush(); out.close(); return true; } catch (FileNotFoundException e) { e.printStackTrace(); return false; } catch (IOException e) { e.printStackTrace(); return false; } }

Putting some reference which might help the library:
For saving an image in Android 10:
https://stackoverflow.com/a/56990305

Plus, putting android:requestLegacyExternalStorage="true" in Manifest won't be a good idea as Google would enforce in Android R or Android 11.

Please update these code to get compatible with Android 10 or above.
Thank You

OutPutFilePath

Hi, I continually get the error

E/Demo App: Output image path required. Use withOutputPath(path) to provide the output image path.

Using the below:

File storageDir = new File(Environment
.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM) + "/Storage/");

    try {
        Intent intent = new ImageEditorIntentBuilder(this, sourceImagePath, storageDir.toString())
                .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(AdvertiserPageSubmitNew.this, 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
    }

I apologize if this seems basic. Any assistance would be appreciated

SelectPictureActivity opens empty grid with names

First of all, thanks for this beautiful library.

I was having Manifest merge issue while adding this library with my application. Later I resolved that issue by updating the manifest file with two attributes:

tools:node="merge"
tools:replace="android:label,android:allowBackup,android:supportsRtl"

After I am having one issue when starting the SelectPictureActivity from my application. It shows empty black grids with gallery names but no images. While clicking the empty grids it returns null.

Here is my application gradle and other info:

Kotlin version: 1.3.50
Ananas Library version: 1.2.3
Included the JavaVersion.VERSION_1_8 in compilerOptions.
Not using RxJava.
minSdkVersion: 21

Thanks in advance.

Activity iamutkarshtiwari.github.io.ananas.editimage.EditImageActivity has leaked window

Hi! First of all, thank you for this very handy tool!

I just want to report that I get the above mentioned exception when using more than one of the editing tools. I will also look into it on my side and report back, but wanted you to know.

The crash log is as follows:

android.view.WindowLeaked: Activity iamutkarshtiwari.github.io.ananas.editimage.EditImageActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView{12dc24ab V.E..... R......D 0,0-480,174} that was originally added here at android.view.ViewRootImpl.<init>(ViewRootImpl.java:530) at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:287) at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91) at android.app.Dialog.show(Dialog.java:325) at iamutkarshtiwari.github.io.ananas.editimage.fragment.FilterListFragment$ProcessingImage.onPreExecute(FilterListFragment.java:172) at android.os.AsyncTask.executeOnExecutor(AsyncTask.java:591) at android.os.AsyncTask.execute(AsyncTask.java:539) at iamutkarshtiwari.github.io.ananas.editimage.fragment.FilterListFragment.enableFilter(FilterListFragment.java:121) at iamutkarshtiwari.github.io.ananas.editimage.adapter.FilterAdapter$1.onClick(FilterAdapter.java:78) at android.view.View.performClick(View.java:5246) at android.view.View$PerformClick.run(View.java:21256) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:145) at android.app.ActivityThread.main(ActivityThread.java:6934) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)

This happened when I tried to apply a filter. When tapping on the appropriate filter, the app crashes with this message. This also seems to happen when going to the "Beauty" tool and trying to apply anything in there.

Thank you.

Regards,
Hermann

Unable to start activity

Unable to start activity ComponentInfo{com.test.app/iamutkarshtiwari.github.io.ananas.editimage.EditImageActivity}: android.view.InflateException: Binary XML file line #94: Binary XML file line #94: Error inflating class iamutkarshtiwari.github.io.ananas.editimage.layout.ZoomLayout

if it is not enabled
JavaVersion.VERSION_1_8
the following error occurs

the following options must be enabled in the build.grandle (Module App) by entering the following code

compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

I also remember to add in the Manifest

  <activity
            android: name = "iamutkarshtiwari.github.io.ananas.picchooser.SelectPictureActivity">
        </ Activity>

        
        <activity
            android: name = "iamutkarshtiwari.github.io.ananas.editimage.EditImageActivity"
            Android: windowSoftInputMode = "adjustPan">
        </ Activity>

to avoid exceptions during the execution phase.

Google Play Console Conflict

Hi Guys,

I've just tried to upload the abb to google play console. Unfortunately it won't allow me to upload.

I've uninstalled the implementation and the new abb uploaded with no problems. But when I reinstall
implementation 'com.github.iamutkarshtiwari:Ananas:1.2.4',
the issue is there again.

Any suggestions on how to look for the conflict/issue?

Cheers

"Error while saving image" when cropping

After applying crop, toast "Error while saving image" is displayed.
Problem is probably in CropFragment , line 201: Single.fromCallable(() -> cropPanel.getCroppedImage());
method getCroppedImage is called from background thread, but it should not, because it works with view (mImageView.clearAnimation())
This problem does not happens on all devices, reproduced on Galaxy Tab S2 , Android 7

Stacktrace:
android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.
at android.view.ViewRootImpl.checkThread(ViewRootImpl.java:7831)
at android.view.ViewRootImpl.invalidateChildInParent(ViewRootImpl.java:1342)
at android.view.ViewGroup.invalidateChild(ViewGroup.java:5449)
at android.view.View.invalidateInternal(View.java:14807)
at android.view.View.invalidate(View.java:14771)
at android.view.View.invalidateParentIfNeeded(View.java:14960)
at android.view.View.clearAnimation(View.java:21431)
at com.theartofdev.edmodo.cropper.CropImageView.getCroppedImage(CropImageView.java:763)
at com.theartofdev.edmodo.cropper.CropImageView.getCroppedImage(CropImageView.java:737)
at iamutkarshtiwari.github.io.ananas.editimage.fragment.crop.CropFragment.lambda$getCroppedBitmap$4$CropFragment(CropFragment.java:201)
at iamutkarshtiwari.github.io.ananas.editimage.fragment.crop.-$$Lambda$CropFragment$Y_hl9FvcrZ26G-Bb-gpLHqbxGQw.call(lambda)
at io.reactivex.internal.operators.single.SingleFromCallable.subscribeActual(SingleFromCallable.java:44)
at io.reactivex.Single.subscribe(Single.java:3575)
at io.reactivex.internal.operators.single.SingleSubscribeOn$SubscribeOnObserver.run(SingleSubscribeOn.java:89)
at io.reactivex.internal.schedulers.ScheduledDirectTask.call(ScheduledDirectTask.java:38)
at io.reactivex.internal.schedulers.ScheduledDirectTask.call(ScheduledDirectTask.java:26)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:272)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:762)

Add RESULT_CANCELLED

In my app, I select an image to edit. Editor opens... Then I changed my mind, do not anything and go back with "<" button.

It returned onActivityResult() with RESULT_OK code. If I edit or not, it returns with same RESULT_OK code.

Enhancment idea

What's the possibility of split the library into modules by feature?, so anybody that wants to use only some features not have to import the whole features.
in mi case i only need 3 features my app size was 12MB with the library now are around 24MB.

I think that split the library on modules it's a really good improvement.
I am in disposition to help with the work.

Best regards.

Ps. sorry for my english.

cannot resolve 'OUTPUT_PATH' in onActivityResult

It seems that the there is no variable defined to get the new image output file path.

String newFilePath = data.getStringExtra(EditImageActivity.OUTPUT_PATH);

OUTPUT_PATH :- not defined
Please assist.

I love it but I think there is something to be improved

According to your code, if I want to save the image, it will return to the last activity, and I will get the url in the OnActivityResult. But I want to go to the next activity since the user wants to send a post to the server.

Pinch to zoom on image not working!

Hello, Pinch to zoom feature not working for me while editing the image. Is there something I need to do to enable it? Or it should work by default. Or this feature is not present currently in the api. Please let me know regarding this. That'll be a big help. Thank you.

select multi photo

Hi! First of all, thank you for this very handy tool!

If you can edit multiple photos one after the other, please apply if there is a way.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.