1.0.8 • Published 3 years ago

react-native-image-filter-android v1.0.8

Weekly downloads
-
License
-
Repository
github
Last release
3 years ago

react-native-image-filter-android

Getting started

$ npm install react-native-image-filter-android --save

Mostly automatic installation

$ react-native link react-native-image-filter-android

Manual installation

iOS

  1. In XCode, in the project navigator, right click LibrariesAdd Files to [your project's name]
  2. Go to node_modulesreact-native-image-filter-android and add RNImageFilterAndroid.xcodeproj
  3. In XCode, in the project navigator, select your project. Add libRNImageFilterAndroid.a to your project's Build PhasesLink Binary With Libraries
  4. Run your project (Cmd+R)<

Android

  1. Open up android/app/src/main/java/[...]/MainActivity.java
  • Add import com.reactlibrary.RNImageFilterAndroidPackage; to the imports at the top of the file
  • Add new RNImageFilterAndroidPackage() to the list returned by the getPackages() method
  1. Append the following lines to android/settings.gradle:
    include ':react-native-image-filter-android'
    project(':react-native-image-filter-android').projectDir = new File(rootProject.projectDir, 	'../node_modules/react-native-image-filter-android/android')
  2. Insert the following lines inside the dependencies block in android/app/build.gradle:
      compile project(':react-native-image-filter-android')

Windows

Read it! :D

  1. In Visual Studio add the RNImageFilterAndroid.sln in node_modules/react-native-image-filter-android/windows/RNImageFilterAndroid.sln folder to their solution, reference from their app.
  2. Open up your MainPage.cs app
  • Add using Image.Filter.Android.RNImageFilterAndroid; to the usings at the top of the file
  • Add new RNImageFilterAndroidPackage() to the List<IReactPackage> returned by the Packages method

Usage

Import Library

import FilterImage from 'react-native-image-filter-android';

Scale Down Image

   const res= await FilterImage.ScaleDownImage(Image,Scale); 
	//Image: Input URI of image (String)
	//Scale: The Factor by which you want to reduce the width and height of the image (Number)
   console.log(res);
	//res: The Output URI of the Image (String)

Set Contrast Of Image

     const res=await FilterImage.SetContrast(Image,Contrast);
	//Image: Input URI of image (String)
	//Contrast: The Contrast that you want to apply the Image (Number)
     console.log(res);
	 //res: The Output URI of the Image (String)

Set Hue Of Image

     const res=await FilterImage.SetHue(Image,Hue);
	//Image: Input URI of image (String)
	//Hue: The Hue that you want to apply the Image (Number)
     console.log(res);
	 //res: The Output URI of the Image (String)

Set Saturation Of Image

    const res=await FilterImage.SetSaturation(Image,Saturation);
	//Image: Input URI of image (String)
	//Saturation: The Saturation that you want to apply the Image (Number)
    console.log(res);
	//res: The Output URI of the Image (String)

Set Brightness Of Image

  const res=await FilterImage.SetBrightness(Image,Brightness);
	//Image: Input URI of image (String)
	//Brightness: The Brightness that you want to apply the Image (Number)
  console.log(res);
	//res: The Output URI of the Image (String)

Sharpen Image

  const res=await FilterImage.SharpenImage(Image,Sharpen);
	//Image: Input URI of image (String)
	//Sharpen: The amount by which you want to sharpen the image (Number)
  console.log(res);
	//res: The Output URI of the Image (String)

Set Sepia Filter

  const res=await FilterImage.SetSepiaFilter(Image);
	//Image: Input URI of image (String)
  console.log(res);
	//res: The Output URI of the Image (String)

Mirror Image

  const res=await FilterImage.MirrorImage(Image,Type);
	//Image: Input URI of image (String)
	//Type: If Type is 1, the image will be mirrored horizontally (Number)
	//Type: If Type is 2, the image will be mirrored vertically (Number)
  console.log(res);
	//res: The Output URI of the Image (String)

Rotate Image by any angle

    const res=await FilterImage.RotateImage(Image,Rotation);
	//Image: Input URI of image (String)
	//Rotation: The amount by which you want to rotate the image (Number)
    console.log(res);
	//res: The Output URI of the Image (String)

Set Blue Filter Of Image

  const res=await FilterImage.SetBlueFilter(Image);
	//Image: Input URI of image (String)
  console.log(res);
	//res: The Output URI of the Image (String)

Set Blur Filter Of Image

  const res=await FilterImage.SetBlurFilter(Image);
	//Image: Input URI of image (String)
  console.log(res);
	//res: The Output URI of the Image (String)

Set GrayScale Of Image

    const res=await FilterImage.SetGrayScale(Image);
	//Image: Input URI of image (String)
    console.log(res);
	//res: The Output URI of the Image (String)

Set Green Filter Of Image

  const res=await FilterImage.SetGreenFilter(Image);
	//Image: Input URI of image (String)
  console.log(res);
	//res: The Output URI of the Image (String)

Set Negative Filter Of Image

  const res=await FilterImage.SetNegative(Image);
	//Image: Input URI of image (String)
  console.log(res);
	//res: The Output URI of the Image (String)

Set Red Filter Of Image

  const res=await FilterImage.SetRedFilter(Image);
	//Image: Input URI of image (String)
  console.log(res);
	//res: The Output URI of the Image (String)

Methods

MethodReturn TypeDescription
ScaleDownImageStringThis method is used to reduce the width and height of the image, by passing a scale. The scale is an integer value. The new width and height are calculated as width'=width / 2^scale, height' = height / 2^scale. Use this method to reduce width and height of an image for faster processing
SetContrastStringThis method is used to apply contrast to an image
SetHueStringThis method is used to apply hue to an image
SetSaturationStringThis method is used to apply saturation to an image
SetBrightnessStringThis method is used to apply brightness to an image. Any value less than or equal to 0 will return the original image. If the brightness is between 0 and 1, it will darken the image
SharpenImageStringThis method is used to sharpen an image. Any value less than or equal to 0 will return the original image
SetSepiaFilterStringThis method is used to apply sepia filter to an image
MirrorImageStringThis method is used to mirror an image horizontally or vertically
RotateImageStringThis method is used to rotate an image with a specified angle
SetBlueFilterStringThis method is used to apply blue filter to an image
SetBlurFilterStringThis method is used to apply blur filter to an image
SetGrayScaleStringThis method is used to apply grayscale filter to an image
SetGreenFilterStringThis method is used to apply green filter to an image
SetNegativeStringThis method is used to apply negative filter to an image
SetRedFilterStringThis method is used to apply red filter to an image

Demo

Alt Text