Git Product home page Git Product logo

androidphotofilters's Introduction

PhotoFiltersSDK

License Android Arsenal

PhotoFiltersSDK aims to provide fast, powerful and flexible image processing instrument for creating awesome effects on any image media.

Library supports OS on API 15 and above.

PhotoFilters gif

Features

PhotoFiltersSDK processes filter on any Image within fraction of second since processing logic is in NDK. At present following image filters are included:

Library also comes with inbuilt Sample Filters (Refer SampleFitlers.java). Implementation is straightforward:

Filter fooFilter = SampleFilters.getBlueMessFilter();
Bitmap outputImage = fooFilter.processFilter(inputImage);

Implementation

Adding Dependency

Simply add Dependency on artifact in your build.gradle :

dependencies {
    compile 'com.github.zomato:androidphotofilters:1.0.2'
    ...

OR

Copy|Paste photofilterssdk from the repo to your project and include photofiltersdk in your settings.gradle like this :

include ':photofilterssdk'

Add dependency in your build.gradle :

compile project(':photofilterssdk')

Usage

Load native library in your activity :

public class MainActivity extends AppCompatActivity {
    static
    {
        System.loadLibrary("NativeImageProcessor");
    }
    ...

then

Filter myFilter = new Filter();
myFilter.addSubFilter(new BrightnessSubFilter(30));
myFilter.addSubFilter(new ContrastSubFilter(1.1f));
Bitmap outputImage = myFilter.processFilter(inputImage);

Above code snippet will give you outputImage with increased brightness and contrast. You can further refer example project.

Documentation

Although there are few inbuilt filters already present, you may want to create and customize one specific to your need and show your creativity. For that you would require to know how all the Subfilters can be used. Let me take you through all of them.

ToneCurveSubfilter

This is most awesome filter present in this library which differentiates PhotoFiltersSDK from other image processing libraries out there. ToneCurveSubFilter applies the changed RGB Channel curve to create effect on image.

CurveDialog

Here is the code snippet the apply the above RGB curve on an image :

Filter myFilter = new Filter();
Point[] rgbKnots;
rgbKnots = new Point[3];
rgbKnots[0] = new Point(0, 0);
rgbKnots[1] = new Point(175, 139);
rgbKnots[2] = new Point(255, 255);
       
myFilter.addSubFilter(new ToneCurveSubfilter(rgbKnots, null, null, null));
Bitmap outputImage = myFilter.processFilter(inputImage);

The results are nearly same as we would see in photoshop and other tools. We can also specify knots for Red, Green and Blue channels (in the ToneCurveSubfilter's constructor).

SaturationSubfilter

This fitler can be used to tweak color saturation of an image. Here is the example :

Filter myFilter = new Filter();
myFilter.addSubFilter(new SaturationSubfilter(1.3f));
Bitmap outputImage = myFilter.processFilter(inputImage);

SaturationSubfilter takes float as an argument and has no effect for value 1.

ColorOverlaySubfilter

Increases the specified red, green and blue values for each pixel in an image.

Filter myFilter = new Filter();
myFilter.addSubFilter(new ColorOverlaySubfilter(100, .2f, .2f, .0f));
Bitmap outputImage = myFilter.processFilter(inputImage);

ContrastSubfilter

To change the contrast levels of an image use this filter :

Filter myFilter = new Filter();
myFilter.addSubFilter(new ContrastSubfilter(1.2f));
Bitmap outputImage = myFilter.processFilter(inputImage);

ContrastSubfilter takes float as an argument where value 1 has no effect on the image.

BrightnessSubfilter

As the name suggest, this filter is used for changing brightness levels :

Filter myFilter = new Filter();
myFilter.addSubFilter(new BrightnessSubfilter(30));
Bitmap ouputImage = myFilter.processFilter(inputImage);

BrightnessSubfilter takes int as an argument where value 0 has no effect. Negative values can be used to decrease brightness of the image.

VignetteSubfilter

This filter can be used to put vignette effect on the image.

Filter myFilter = new Filter();
myFilter.addSubFilter(new VignetteSubfilter(context, 100));
Bitmap outputImage = myFilter.processFilter(inputImage);

VignetteSubfilter takes int as an argument whoes value ranges from 0-255, which defines intesity of the vignette effect.

Proguard

If you are using proguard, consider adding the following to your proguard rules:

-keep class com.zomato.photofilters.** {*;}
-keepclassmembers  class com.zomato.photofilters.** {*;}

License

This library falls under Apache v2

androidphotofilters's People

Contributors

archie94 avatar djnotes avatar varunest avatar ylogx 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  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

androidphotofilters's Issues

New logo proposal

Hello @Zomato, today while exploring GitHub looking for interesting projects found yours and I would love to contribute by designing a logo for it since I'm a designer in development and an open source enthusiast. We would be working together to create the design that fits best. Of course it's totally free and you can quit whenever you want. In case you agree, please share any preferences you may have about colours, shapes, etc.

Best regards.

Files not getting imported in project.

ViewHelper.setAlpha(viewToAnimate, .0f);
com.nineoldandroids.view.ViewPropertyAnimator.animate(viewToAnimate).alpha(1).setDuration(250).start();

Unable to import ViewHelper and com.nineoldandroids.view.ViewPropertyAnimator.animate.
Is NDK needed to be configured in my project?

Black & White and Sepia Tone

Hi,

Thanks for library. Its really great. I am bad at image skills. Can you please provide b&w and sepia effect? I cant figure out to how to do it with given sub filters.

Thanks

Trying to get in touch regarding a security issue

Hey there!

I'd like to report a security issue but cannot find contact instructions on your repository.

If not a hassle, might you kindly add a SECURITY.md file with an email, or another contact method? GitHub recommends this best practice to ensure security issues are responsibly disclosed, and it would serve as a simple instruction for security researchers in the future.

Thank you for your consideration, and I look forward to hearing from you!

(cc @huntr-helper)

Filter Value Range?

What is the minimum and maximum value for these filters?

BrightnessSubFilter
ContrastSubFilter
SaturationSubFilter

Thanks!

FilterPack.getFilterPack(getApplicationContext()) not found

for (Filter filter : FilterPack.getFilterPack(getApplicationContext())) {
ThumbnailItem thumbnailItem = new ThumbnailItem();
thumbnailItem.image = createScaledBitmap;
thumbnailItem.filter = filter;
ThumbnailsManager.addThumb(thumbnailItem);
}

FilterPack not imported
Is it changed or removed ?
How to use ?

java.lang.NullPointerException: Attempt to read from field 'float com.zomato.photofilters.geometry.Point.x' on a null object reference

E/InputEventReceiver: Exception dispatching input event.
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.mobilix.photoeditor, PID: 6354
java.lang.NullPointerException: Attempt to read from field 'float com.zomato.photofilters.geometry.Point.x' on a null object reference
at com.zomato.photofilters.imageprocessors.subfilters.ToneCurveSubFilter.sortPointsOnXAxis(ToneCurveSubFilter.java:93)
at com.zomato.photofilters.imageprocessors.subfilters.ToneCurveSubFilter.process(ToneCurveSubFilter.java:64)
at com.zomato.photofilters.imageprocessors.Filter.processFilter(Filter.java:115)
at editor.toolsmanager.FilterTools$FilterController.update(FilterTools.java:266)
at editor.toolsmanager.FilterTools$2.onProgressChanged(FilterTools.java:181)
at android.widget.SeekBar.onProgressRefresh(SeekBar.java:98)

New idea for AndroidPhotoFilters

Thank you for writing this library. It helped me a lot during the project development process. When integrating into my project I made changes in your library to improve performance. I hope this will help you and the community:

1. Combined with Glide:

Yes, I have integrated the library into the Transformation of glide. With the cache mechanism and excellent flow management of glide, it helps me optimize every time I want to filter and release bitmaps when I no longer use them.

    @Override
    protected Bitmap transform(@NonNull BitmapPool pool, @NonNull Bitmap toTransform, int outWidth, int outHeight) {
        Bitmap bitmap = TransformationUtils.fitCenter(pool, toTransform, outWidth, outHeight);
        return filter.processFilter(bitmap);
    }

Source: FilterTransformation

2. Release bitmap:

When using the library, I encountered a lot of Out of memory errors. I tried to find a way and there were some solutions:

a) Create copy bitmap:

    public static Bitmap doSaturation(Bitmap inputImage, float level) {
        int width = inputImage.getWidth();
        int height = inputImage.getHeight();
        int[] pixels = new int[width * height];

        inputImage.getPixels(pixels, 0, width, 0, 0, width, height);
        NativeImageProcessor.doSaturation(pixels, level, width, height);

        Bitmap outputImage = inputImage.copy(inputImage.getConfig(), true);
        outputImage.setPixels(pixels, 0, width, 0, 0, width, height);
        return outputImage;
    }

Source: ImageProcessor

b) Recycle bitmap:

    public Bitmap processFilter(Bitmap inputImage) {
        Bitmap outputImage = inputImage;
        for (int i = 0; i < subFilters.size(); i++) {
            SubFilter subFilter = subFilters.get(i);
            Bitmap bitmap = outputImage;
            outputImage = subFilter.process(outputImage);
            if (i != 0 && bitmap != outputImage) {
                bitmap.recycle();
            }
        }
        return outputImage;
    }

Source: Filter

This is the result:

Alt Text

Project:

AndroidFilters

Thank you for reading my post, thank you

Add Multiple Image

Great tutorial.

Hi, I need to add multiple image filter can you please tell me how can I do?

Null point exeption when getPack from FilterPack

When i open image from gallery:

if (requestCode == PICKIMAGE) {
                data?.data?.let {
                    val bitmap = BitmapUtils.getBitmapFromGallery(this, it, 800, 800)

                    original_filter_bitmap.recycle()
                    final_bitmap.recycle()
                    filtered_bitmap.recycle()
                    original_filter_bitmap = bitmap.copy(Bitmap.Config.ARGB_8888, true)
 imageFiltersFragment!!.displayThumbNail(original_filter_bitmap)

and try to display this image in thumbnail

open fun displayThumbNail(bitmap: Bitmap?) {
        var runnable = Runnable {

            var thumbImg: Bitmap?
            if (bitmap == null)
                thumbImg = BitmapUtils.getBitmapFromAsests(activity, MainActivity.pictureName, 100, 100)
            else
                thumbImg = Bitmap.createScaledBitmap(bitmap, 100, 100, false)

            if (thumbImg == null)
                return@Runnable

            ThumbnailsManager.clearThumbs()
            thumbnailList?.clear()
            val thumbnailItem = ThumbnailItem()
            thumbnailItem.image = thumbImg
            thumbnailItem.filterName = "Normal"
            ThumbnailsManager.addThumb(thumbnailItem)
            var filters = FilterPack.getFilterPack(activity!!) as MutableList
            for (f in filters) {
                val item = ThumbnailItem()
                item.image = thumbImg
                item.filter = f
                item.filterName = f.name
                ThumbnailsManager.addThumb(item)
                Log.d("filterpack", f.name)
            }
            thumbnailList!!.addAll(ThumbnailsManager.processThumbs(activity))
            activity!!.runOnUiThread {

                thumbnailAdapter.notifyDataSetChanged()

            }
        }

It throws this exeption
kotlin.KotlinNullPointerException
at com.example.sg772.textonimage.ImageFiltersFragment$displayThumbNail$runnable$1.run(ImageFiltersFragment.kt:110)

line 110: var filters = FilterPack.getFilterPack(activity!!) as MutableList
P.S
When i dont open image from gallery and work with default image , everythings works fine

Illegal State Exception

when i do i got illegalstateexception
Filter filter = SampleFilters.getBlueMessFilter();
filter.addSubFilter(new ContrastSubfilter(1.1f));
filter.addSubFilter(new BrightnessSubfilter(110));
filter.addSubFilter(new SaturationSubfilter(1.3f));
Bitmap outputImage = filter.processFilter(inputimage);

Crash on System.loadLibrary("NativeImageProcessor"); on First launch

java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file ""],nativeLibraryDirectories=[oXNkeS75H_GZt21u1A6laQ==/lib/arm, oXNkeS75H_GZt21u1A6laQ==/base.apk!/lib/armeabi-v7a, /system/lib, /system/vendor/lib]]] couldn't find "libNativeImageProcessor.so"

missing util package

Firstly, I installed the dependency of zomato in gardle.build file

implementation 'com.github.zomato:androidphotofilters:1.0.2'

And it is installed successfully but when I try to get ThumbnailItem from com.zomato.photofilters.util.ThumbnailItem I found that the utiil package is missed.

libNativeImageProcessor not found

dlopen failed: library "libNativeImageProcessor.so" not found

After writing this also

static {
System.loadLibrary("NativeImageProcessor");
}

Please resolve asap

cannot resolve method process

Filter fooFilter = SampleFilters.getBlueMessFilter();
Bitmap outputImage = fooFilter.process();

In the above line process cannot resolve method

My Code:

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;

import com.zomato.photofilters.SampleFilters;
import com.zomato.photofilters.imageprocessors.Filter;
import com.zomato.photofilters.imageprocessors.subfilters.BrightnessSubfilter;
import com.zomato.photofilters.imageprocessors.subfilters.ContrastSubfilter;

public class MainActivity extends AppCompatActivity {

    static
    {
        System.loadLibrary("NativeImageProcessor");
    }

ImageView img;
Bitmap outputImage;

int i=0;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    img=(ImageView)findViewById(R.id.img_id);

    Filter fooFilter = SampleFilters.getBlueMessFilter();
    Bitmap outputImage = fooFilter.process();

    img.setImageResource(R.drawable.img_input);


}

}

library is not working

I'm following the steps showed in project to add library but when i try to use filter is gives me IllegalstateException ? why this is happening ? thanks in advance

Error while running the app

I'm getting error while running the app . I'm using latest android studio(3.2). The error i'm getting is No toolchains found in the NDK toolchains folder for ABI with prefix: mips64el-linux-android.

Filter in percentage

Hi, I have to replicate some of these filters: http://www.cssfilters.co/
In the css style I can manage percentage of:

  • contrast
  • brightness
  • saturation
  • other...
    In my application I use (for example) this code to create 1977 filter:

1977 ==> contrast 110% | Brightness 110% | Saturate 130%

public static Filter get1977() {
Filter filter = new Filter();
filter.addSubFilter(new ContrastSubfilter(1.1f));
filter.addSubFilter(new BrightnessSubfilter(110));
filter.addSubFilter(new SaturationSubfilter(1.3f));
return filter;
}

But the result is not the same as css style.
Can you help me to know I can set 110% of contrast, 100% of brightness and 130% of saturation? I have tryed but I don't know as fraction in ContrastSubfilter() and other operate with float values.

Thanks in advance,
Mattia

Release new version

With changes in the API from PR #35, we'll have to release a new version of the library.

@varunest How is the release uploaded right now? AFAIK it is from your account only. Is there a way to share access to release with more team members?

java.lang.IllegalArgumentException: The Path cannot loop back on itself. in ToneCurveSubfilter

I added the following points in the ToneCurveSubfilter under the rgb part.

Filter myFilter = new Filter();
Point[] rgbKnots;
rgbKnots = new Point[5];
rgbKnots[0] = new Point(0, 0);
rgbKnots[1] = new Point(51, 152);
rgbKnots[2] = new Point(73, 172);
rgbKnots[3] = new Point(204, 219);
rgbKnots[4] = new Point(255, 255);
myFilter.addSubFilter(new ToneCurveSubfilter(rgbKnots, null, null, null));
Bitmap outputImage = myFilter.process(inputImage);

The app crashes saying

java.lang.IllegalArgumentException: The Path cannot loop back on itself.
at android.view.animation.PathInterpolator.initPath(PathInterpolator.java:181)
at android.view.animation.PathInterpolator.(PathInterpolator.java:61)
at com.zomato.photofilters.geometry.BezierSpline.getOutputPointsForNewerDevices(BezierSpline.java:61)

I am new to android image processing and am not able to resolve the issue. Please help

Typo, Incorrect Documentation

The VignetteSubFilter class is spelled wrong ("SubFitler"), has different capitalization than in documentation, and takes an extra parameter (Context) not described in documentation.

IllegalStateException

I'm not sure what's the issue here. It just throws IllegalStateException at the last line (Where I'm saving the output to Bitmap output). I followed all the proper steps. Can't figure out the problem.

Bitmap output =filter.processFilter(oldBitmap);

Recyclerview Filtered Image Stretched.

Hi, this is very good library for filters and i use it, but when i select any photo and it reflect to recyclerview's item which is shows how image looks like after selecting this filter, that images stretched, i used center crop in item imageview but not worked.

Anyone who solved this issue please give me suggestion or solution for it.

Thanks

error: cannot find symbol import com.zomato.photofilters.imageprocessors.subfilters.ColorOverlaySubfilter

CAN YOU HELP ME SOLVING THIS ISSUE PLEAS SIR ;
JAVA :
import com.zomato.photofilters.imageprocessors.subfilters.ColorOverlaySubfilter;
import com.zomato.photofilters.imageprocessors.subfilters.ContrastSubfilter;
import com.zomato.photofilters.imageprocessors.subfilters.ToneCurveSubfilter;
import com.zomato.photofilters.imageprocessors.subfilters.VignetteSubfilter;


GRADEL :
implementation 'com.github.zomato:androidphotofilters:1.0.2'

PMEM_CACHE_FLUSH error

when I apply a filter on bitmap, android studio shows infinite messages like this :

W/QualcommCameraHardware7225a: MemoryCacheFlush : fd 73 size 155648 PMEM_CACHE_FLUSH error Invalid argument (22)

Is there any problem with this??

No Method for saving photo

Hello,

Great library for photo edit. Some methods are needed like save photo to a file and provide path in the callback. I didn't find any save method in the library.

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.