Coder Social home page Coder Social logo

gregorynative / react-native-gl-image-filters Goto Github PK

View Code? Open in Web Editor NEW
243.0 5.0 35.0 7.46 MB

React-Native image filters using gl-react

License: MIT License

JavaScript 100.00%
react-native gl-react gl-react-native image-filters gl-react-expo gl-react-dom expo gl opengl react

react-native-gl-image-filters's Introduction

Stand With Ukraine

icon react-native-gl-image-filters

react-native-gl-image-filters is released under the MIT license. Current npm package version. Current npm package downloads. Expo snack. Stackblitz project.

OpenGL bindings for React Native to implement complex effects over images and components, in the descriptive VDOM paradigm. You can use predefined filters:

  • blur
  • contrast
  • saturation
  • brightness
  • hue
  • negative
  • sepia
  • sharpen
  • temperature
  • exposure.

gl-react-native is an implementation of gl-react for react-native. Please read the main gl-react README and gl-react-native README for more information.

Table of Contents

API

Props

Props for ImageFilters Component

Name Description Type Required Default Value
children Inner component or url for image Any +
width Width of component Number +
height Height of component Number +
hue Hue filter Number 0
blur Blur filter Number 0
sepia Sepia filter Number 0
sharpen Sharpen filter Number 0
negative Negative filter Number 0
contrast Contrast filter Number 1
saturation Saturation filter Number 1
brightness Brightness filter Number 1
temperature Temperature filter Number 6500
exposure Exposure filter Number 0
๐Ÿ†• colorOverlay Color Overlay with the length of 4 (RGBA format). Values must be a real value between 0 and 255. Array [0.0, 0.0, 0.0, 0.0]

Constants

DefaultValues

Can be used to set filter to default one manually.

interface DefaultValues {
  sepia: number;
  hue: number;
  blur: number;
  sharpen: number;
  negative: number;
  temperature: number;
  brightness: number;
  contrast: number;
  saturation: number;
  exposure: number;
  colorOverlay: Array<number>;
}
Usage example
import ImageFilters, { Constants } from 'react-native-gl-image-filters';

...

state = {
  blur: 4,
};

...

resetFilter = () => {
  this.setState({
    blur: Constants.DefaultValues.blur,
  });
}

DefaultPresets

Can be used to list available presets.

interface DefaultPresets extends Array<DefaultPreset> {}
interface DefaultPreset {
  name: string,
  description: string,
  preset: Preset,
}
interface Preset {
  sepia?: number;
  hue?: number;
  blur?: number;
  sharpen?: number;
  negative?: number;
  temperature?: number;
  brightness?: number;
  contrast?: number;
  saturation?: number;
  exposure?: number;
}
Usage example
import ImageFilters, { Constants } from 'react-native-gl-image-filters';

...

<>
  {Constants.DefaultPresets.map(item =>
    <View>
      <Text>{item.name}</Text>
      <Text>{item.description}</Text>
      <Surface>
        <ImageFilters {...item.preset}>
          {{ uri: 'https://i.imgur.com/5EOyTDQ.jpg' }}
        </ImageFilters>
       </Surface>
    </View>
  )}
</>

Presets

Use predefined presets.

import { Presets } from 'react-native-gl-image-filters';

Presets.NoPreset;
Presets.AmaroPreset;
Presets.ClarendonPreset;
Presets.DogpatchPreset;
Presets.GinghamPreset;
Presets.GinzaPreset;
Presets.HefePreset;
Presets.LudwigPreset;
Presets.SkylinePreset;
Presets.SlumberPreset;
Presets.SierraPreset;
Presets.StinsonPreset;

...

<ImageFilters {...Presets.StinsonPreset}>
  {{ uri: 'https://i.imgur.com/5EOyTDQ.jpg' }}
</ImageFilters>

Utils

createPreset

Available for creating own presets.

import ImageFilters, { Utils } from 'react-native-gl-image-filters';

const MyOwnPreset = Utils.createPreset({
  brightness: .1,
  saturation: -.5,
  sepia: .15,
});

...

<ImageFilters {...MyOwnPreset}>
  {{ uri: 'https://i.imgur.com/5EOyTDQ.jpg' }}
</ImageFilters>

Recommended Min and Max range for each filter

Name Min. Value Max. Value
hue 0 6.3
blur 0 30
sepia -5 5
sharpen 0 15
negative -2 2
contrast -10 10
saturation 0 2
brightness 0 5
temperature 0 40000
exposure -1 1

Installation

Installation for React Native

npm i --save react-native-gl-image-filters
npm i --save gl-react@^4.0.1
npm i --save gl-react-native@^4.0.1
npm i --save buffer@^5.4.3
npm i --save react-native-unimodules@^0.7.0

or

yarn add react-native-gl-image-filters
yarn add gl-react@^4.0.1
yarn add gl-react-native@^4.0.1
yarn add buffer@^5.4.3
yarn add react-native-unimodules@^0.7.0

Configure your React Native Application

on iOS:

https://github.com/unimodules/react-native-unimodules#-configure-ios

on Android:

https://github.com/unimodules/react-native-unimodules#-configure-android

Installation on Expo

npm i --save react-native-gl-image-filters
npm i --save expo-gl
npm i --save gl-react@^4.0.1
npm i --save gl-react-expo@^4.0.1
npm i --save buffer@^5.4.3

or

yarn add react-native-gl-image-filters
yarn add expo-gl
yarn add gl-react@^4.0.1
yarn add gl-react-expo@^4.0.1
yarn add buffer@^5.4.3

Installation on React Web

npm i --save react-native-gl-image-filters
npm i --save gl-react@^4.0.1
npm i --save gl-react-dom@^4.0.1

or

yarn add react-native-gl-image-filters
yarn add gl-react@^4.0.1
yarn add gl-react-dom@^4.0.1

Usage

Usage with React Native

Example here: examples/react-native

Usage with Expo

Snack: https://snack.expo.io/@gregoryrn/expo-gregorynative-react-native-gl-image-filters
Example here: examples/expo

Usage with React web

Blitz: https://stackblitz.com/edit/react-native-gl-image-filters-web-example
Example here: examples/web

react-native-gl-image-filters's People

Contributors

dependabot[bot] avatar gregorynative avatar mbpictures 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

react-native-gl-image-filters's Issues

Captured image quality is too low and image is black inside surface

Hi, i am using gl-react, gl-react-native & react-native-gl-image-filters for setting saturation, contrast and brightness to my image. Following are the versions :

"gl-react": "^2.3.1",
"gl-react-native": "^2.48.0",
"react-native-gl-image-filters": "0.0.4"

The problem is when i try to load some large image in my image component inside surface, it is always black. Following is my code for it :

<Surface preload={[{ uri: `data:image/png;base64,${this.state.image.path}` }]} onLoad={() => { }} width={width} height={width} ref={'filtered_image'}>
                        <ImageFilters {...filter}>
                            <Image key={this.state.image.size} style={{ width: width, height: width }} resizeMode='contain'
                                source={{ uri: `data:image/png;base64,${this.state.image.data}` }} />
                        </ImageFilters>
                    </Surface>

I am using preload as i have seen in many issues but its still not working. Maybe i am using preload wrong.

And for capturing the image :

 this.refs.filtered_image.captureFrame({ quality: 1 }).then((newImage) => {
                console.log('finale image', newImage)
            });

The result of captureFrame is very low quality. 10mb images are processed to 1 mb. Any help would be appreciated.

How can i contain the image in ImageFilters?

Screenshot_20201013-104541_ISAC_SIMO 1
Screenshot_20201013-104547_ISAC_SIMO 1

Here the cropped image has the different aspect ratio . After cropping the image, the image gets passed to the ImageFilter component which stretches the image and the same image gets captured with glView.Capture() method which is very annoying.. Can somebody help me on this?

ใ€Questionใ€‘How to display local image๏ผŸ

Hi, i am using your library.
and i have a question.

I'm using expo-image-picker and app user can pick up a image from photo gallery.
so how to display picked image and filter it.

<Surface style={style} ref={ref}>
	<ImageFilters
		hue={imageFilter.hue}
		blur={imageFilter.blur}
		sepia={imageFilter.sepia}
		sharpen={imageFilter.sharpen}
		negative={imageFilter.negative}
		contrast={imageFilter.contrast}
		saturation={imageFilter.saturation}
		brightness={imageFilter.brightness}
		temperature={imageFilter.temperature}
		exposure={imageFilter.exposure}
		width={width}
		height={height}
	>
		{source}
	</ImageFilters>
</Surface>

this is my code.
but there is black

please kindly check

ImageFilters parameter value ranges?

Question: where can I find information / documentation about allowed ImageFilters parameter values / ranges - e.g. what values are allowed for blur, hue, saturation, etc. and what is their effect? (Note: I'm unable to understand the GLSL fragments where these parameters are used in the source code).

custom filter for black and white

Hello everyone, i need to apply black and white filter to a image..There is no predefined filter for B & W.. Is there a way to create such filter?

Unable to import default presets

My apologies if I'm overlooking something simple here, but I cannot import the values for the Presets.

import { Presets } from 'react-native-gl-image-filters';

When I try to use these values, it tells me that Presets is a type interface, which doesn't seem right to me. I was expecting to be able to use the presets like in the Readme (below)

<ImageFilters {...**Presets.StinsonPreset**}> {{ uri: 'https://i.imgur.com/5EOyTDQ.jpg' }} </ImageFilters>

I'm relatively new to React Native, so please let me know if I'm doing this wrong.

Thank you!

Issue while loading remote image

Hi!

I saw the documentations leaks a bit: The type definitions instruct me to have a child component of type "ReactElement", while the docu says an object with key "uri" will also work.

So I added an image component as a child of the image filter component, but it doesn't work (warning: node can not be rendered).

I adjusted the type file so it accepts an object with Uri and a react element and used the object variant and everything works now. So please update the type definitions!

Thanks already for your awesome work! :)

All packages (as mentioned in your snack example) installed properly still getting the following errors on expo

[11:24:21] Warning: Failed context type: The context glSurface is marked as required in Node, but its value is undefined.
at node_modules\react-native\Libraries\LogBox\LogBox.js:174:8 in registerError
at node_modules\react-native\Libraries\LogBox\LogBox.js:60:8 in errorImpl
at node_modules\react-native\Libraries\LogBox\LogBox.js:34:4 in console.error
at node_modules\expo\build\environment\react-native-logs.fx.js:27:4 in error
at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:85:4 in printWarning
at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:61:16 in error
at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:4561:15 in checkPropTypes
at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:4695:20 in getMaskedContext
at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:7722:24 in constructClassInstance
at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:12729:26 in updateClassComponent
at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:19794:22 in beginWork$1
at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:18563:22 in performUnitOfWork
at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:18499:21 in workLoopSync
at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:18464:18 in renderRootSync
at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:18158:31 in performSyncWorkOnRoot
at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:5911:33 in runWithPriority$argument_1
at node_modules\scheduler\cjs\scheduler.development.js:468:23 in unstable_runWithPriority
at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:5906:23 in flushSyncCallbackQueueImpl
at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:5893:28 in flushSyncCallbackQueue
at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:18211:28 in batchedUpdates$1
at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:2534:29 in batchedUpdates
at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:2680:16 in _receiveRootNodeIDEvent
at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:2800:27 in receiveTouches
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:414:4 in __callFunction
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:113:6 in __guard$argument_0
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:365:10 in __guard
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:112:4 in callFunctionReturnFlushedQueue

[11:24:21] Warning: Failed context type: The context glParent is marked as required in Node, but its value is undefined.
at node_modules\react-native\Libraries\LogBox\LogBox.js:174:8 in registerError
at node_modules\react-native\Libraries\LogBox\LogBox.js:60:8 in errorImpl
at node_modules\react-native\Libraries\LogBox\LogBox.js:34:4 in console.error
at node_modules\expo\build\environment\react-native-logs.fx.js:27:4 in error
at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:85:4 in printWarning
at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:61:16 in error
at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:4561:15 in checkPropTypes
at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:4695:20 in getMaskedContext
at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:7722:24 in constructClassInstance
at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:12729:26 in updateClassComponent
at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:19794:22 in beginWork$1
at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:18563:22 in performUnitOfWork
at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:18499:21 in workLoopSync
at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:18464:18 in renderRootSync
at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:18158:31 in performSyncWorkOnRoot
at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:5911:33 in runWithPriority$argument_1
at node_modules\scheduler\cjs\scheduler.development.js:468:23 in unstable_runWithPriority
at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:5906:23 in flushSyncCallbackQueueImpl
at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:5893:28 in flushSyncCallbackQueue
at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:18211:28 in batchedUpdates$1
at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:2534:29 in batchedUpdates
at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:2680:16 in _receiveRootNodeIDEvent
at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:2800:27 in receiveTouches
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:414:4 in __callFunction
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:113:6 in __guard$argument_0
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:365:10 in __guard
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:112:4 in callFunctionReturnFlushedQueue

[11:24:21] TypeError: undefined is not an object (evaluating 'this.context.glSurface.RenderLessElement')

This error is located at:
in Node (created by Sepia)
in Sepia (created by ConditionalWrapper)
in ConditionalWrapper
in Unknown (created by ImageFiltersComponent)
in ImageFiltersComponent
in RCTView (created by View)
in View (created by AppContainer)
in RCTView (created by View)
in View (created by AppContainer)
in AppContainer (created by Modal)
in RCTView (created by View)
in View (created by Modal)
in VirtualizedListContextResetter (created by Modal)
in RCTModalHostView (created by Modal)
in Modal
in RCTView (created by View)
in View (created by AnimatedComponent)
in AnimatedComponent
in AnimatedComponentWrapper (created by TouchableOpacity)
in TouchableOpacity
in Unknown
in RCTView (created by View)
in View
in AndroidHorizontalScrollContentView (created by ScrollView)
in AndroidHorizontalScrollView (created by ScrollView)
in ScrollView (created by ScrollView)
in ScrollView
in RCTView (created by View)
in View
in Unknown (created by CameraPage)
in CameraPage (created by App)
in App (created by ExpoRoot)
in ExpoRoot
in RCTView (created by View)
in View (created by AppContainer)
in RCTView (created by View)
in View (created by AppContainer)
in AppContainer
at node_modules\react-native\Libraries\LogBox\LogBox.js:149:8 in registerError
at node_modules\react-native\Libraries\LogBox\LogBox.js:60:8 in errorImpl
at node_modules\react-native\Libraries\LogBox\LogBox.js:34:4 in console.error
at node_modules\expo\build\environment\react-native-logs.fx.js:27:4 in error
at node_modules\react-native\Libraries\Core\ExceptionsManager.js:104:6 in reportException
at node_modules\react-native\Libraries\Core\ExceptionsManager.js:172:19 in handleException
at node_modules\react-native\Libraries\Core\ReactFiberErrorDialog.js:43:2 in showErrorDialog
at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:15792:34 in logCapturedError
at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:15884:20 in update.callback
at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:7199:2 in callCallback
at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:7220:20 in commitUpdateQueue
at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:16632:25 in commitLifeCycles
at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:19216:22 in commitLayoutEffects
at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:93:4 in invokeGuardedCallbackProd
at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:318:2 in invokeGuardedCallback
at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:18952:29 in commitRootImpl
at node_modules\scheduler\cjs\scheduler.development.js:468:23 in unstable_runWithPriority
at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:18791:17 in commitRoot
at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:18192:12 in performSyncWorkOnRoot
at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:5911:33 in runWithPriority$argument_1
at node_modules\scheduler\cjs\scheduler.development.js:468:23 in unstable_runWithPriority
at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:5906:23 in flushSyncCallbackQueueImpl
at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:5893:28 in flushSyncCallbackQueue
at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:18211:28 in batchedUpdates$1
at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:2534:29 in batchedUpdates
at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:2680:16 in _receiveRootNodeIDEvent
at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:2800:27 in receiveTouches
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:414:4 in __callFunction
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:113:6 in __guard$argument_0
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:365:10 in __guard
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:112:4 in callFunctionReturnFlushedQueue

[11:24:21] Warning: Failed context type: The context glSizable is marked as required in Node, but its value is undefined.
at node_modules\react-native\Libraries\LogBox\LogBox.js:174:8 in registerError
at node_modules\react-native\Libraries\LogBox\LogBox.js:60:8 in errorImpl
at node_modules\react-native\Libraries\LogBox\LogBox.js:34:4 in console.error
at node_modules\expo\build\environment\react-native-logs.fx.js:27:4 in error
at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:85:4 in printWarning
at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:61:16 in error
at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:4561:15 in checkPropTypes
at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:4695:20 in getMaskedContext
at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:7722:24 in constructClassInstance
at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:12729:26 in updateClassComponent
at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:19794:22 in beginWork$1
at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:18563:22 in performUnitOfWork
at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:18499:21 in workLoopSync
at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:18464:18 in renderRootSync
at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:18158:31 in performSyncWorkOnRoot
at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:5911:33 in runWithPriority$argument_1
at node_modules\scheduler\cjs\scheduler.development.js:468:23 in unstable_runWithPriority
at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:5906:23 in flushSyncCallbackQueueImpl
at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:5893:28 in flushSyncCallbackQueue
at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:18211:28 in batchedUpdates$1
at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:2534:29 in batchedUpdates
at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:2680:16 in _receiveRootNodeIDEvent
at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:2800:27 in receiveTouches
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:414:4 in __callFunction
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:113:6 in __guard$argument_0
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:365:10 in __guard
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:112:4 in callFunctionReturnFlushedQueue

[11:24:21] TypeError: undefined is not an object (evaluating 'this.context.glSurface.RenderLessElement')

This error is located at:
in Node (created by Sepia)
in Sepia (created by ConditionalWrapper)
in ConditionalWrapper
in Unknown (created by ImageFiltersComponent)
in ImageFiltersComponent
in RCTView (created by View)
in View (created by AppContainer)
in RCTView (created by View)
in View (created by AppContainer)
in AppContainer (created by Modal)
in RCTView (created by View)
in View (created by Modal)
in VirtualizedListContextResetter (created by Modal)
in RCTModalHostView (created by Modal)
in Modal
in RCTView (created by View)
in View (created by AnimatedComponent)
in AnimatedComponent
in AnimatedComponentWrapper (created by TouchableOpacity)
in TouchableOpacity
in Unknown
in RCTView (created by View)
in View
in AndroidHorizontalScrollContentView (created by ScrollView)
in AndroidHorizontalScrollView (created by ScrollView)
in ScrollView (created by ScrollView)
in ScrollView
in RCTView (created by View)
in View
in Unknown (created by CameraPage)
in CameraPage (created by App)
in App (created by ExpoRoot)
in ExpoRoot
in RCTView (created by View)
in View (created by AppContainer)
in RCTView (created by View)
in View (created by AppContainer)
in AppContainer
at node_modules\react-native\Libraries\LogBox\LogBox.js:149:8 in registerError
at node_modules\react-native\Libraries\LogBox\LogBox.js:60:8 in errorImpl
at node_modules\react-native\Libraries\LogBox\LogBox.js:34:4 in console.error
at node_modules\expo\build\environment\react-native-logs.fx.js:27:4 in error
at node_modules\react-native\Libraries\Core\ExceptionsManager.js:104:6 in reportException
at node_modules\react-native\Libraries\Core\ExceptionsManager.js:172:19 in handleException
at node_modules\react-native\Libraries\Core\setUpErrorHandling.js:24:6 in handleError
at node_modules\expo-error-recovery\build\ErrorRecovery.fx.js:12:21 in ErrorUtils.setGlobalHandler$argument_0
at node_modules\regenerator-runtime\runtime.js:63:36 in tryCatch
at node_modules\regenerator-runtime\runtime.js:294:29 in invoke
at node_modules\regenerator-runtime\runtime.js:63:36 in tryCatch
at node_modules\regenerator-runtime\runtime.js:155:27 in invoke
at node_modules\regenerator-runtime\runtime.js:165:18 in PromiseImpl.resolve.then$argument_0
at node_modules\react-native\node_modules\promise\setimmediate\core.js:37:13 in tryCallOne
at node_modules\react-native\node_modules\promise\setimmediate\core.js:123:24 in setImmediate$argument_0
at node_modules\react-native\Libraries\Core\Timers\JSTimers.js:123:14 in _callTimer
at node_modules\react-native\Libraries\Core\Timers\JSTimers.js:177:14 in _callImmediatesPass
at node_modules\react-native\Libraries\Core\Timers\JSTimers.js:437:30 in callImmediates
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:388:6 in __callImmediates
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:132:6 in __guard$argument_0
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:365:10 in __guard
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:131:4 in flushedQueue

Use without expo

I am using RN v0.66 and have tried multiple times with a lot of troubles getting this package to work...

The example looks like it is not using Expo which is amazing, but I believe (please someone correct me if I am wrong) due to react-native-unimodules being deprecated it is no longer possible to use this package?

Cheers.

Cannot able to run example android app: throwing error > Task :expo-permissions:compileDebugKotlin FAILED

> Task :unimodules-core:compileDebugJavaWithJavac

> Task :expo-app-loader-provider:compileDebugJavaWithJavac

> Task :expo-constants:compileDebugJavaWithJavac

> Task :expo-file-system:compileDebugJavaWithJavac

> Task :expo-gl:compileDebugJavaWithJavac

> Task :expo-permissions:compileDebugKotlin

> Task :expo-permissions:compileDebugKotlin FAILED
w: Detected multiple Kotlin daemon sessions at build/kotlin/sessions

undefined is not an object

undefined is not an object (evaluating '_glReact2.default.Shaders')

Sepia.js:25:32

got above error, any ideas?

Using asset-library as URI is resulting in a black surface

Hello! I was wondering why the surface is rendering this black canvas? I cant seem to make this work with expo media library or @react-native-community/cameraroll. I tried using a normal uri from google images and that works fine, just seems like it doesnt like "assets-library://". Any help will be appreciated, thanks!!!

Screen Shot 2021-07-05 at 11 13 27 AM

Screen Shot 2021-07-05 at 11 14 03 AM

gl-react-native is deprecated how do we use `Surface` ?

Hello GregoryNative, This is a nice package, but now the WebGL package for react native has been deprecated. Can you please create on new example with an available option?
Also if you could upgrade the react-gl package it will be helpful.

Thank you.

Transparent PNG Image

How can I pass transparent .png image without GL background, I change the backgroundColor props to transparent in Surface Component but it's still not work

Surface size different than image size

It is currently not possible to have with or height of the image higher than the surface area.

  • Surface should keep the size without distorting the image inside of it.
  • ImageFilter component, which has its own height and width properties, should behave normally respecting the values of its width and height and not be distorted by surface, but only "cutted" when its size is bigger than the surface containing it

Surface + ImageFilters not working properly on Android

I use Surface (from gl-react-expo) and ImageFilters (from "react-native-gl-image-filters) for my project and on iOs it is working.

However, on Android photos with filters are shown properly when visible on the screen for the first time, but then when I scrolldown so given photo is out of screen and come back to it, it doesn't display and only white area is shown.

Why is that? What is the possible fix for that?

Code extract below:

`import { Surface } from "gl-react-expo";
import ImageFilters from "react-native-gl-image-filters";

...

        <Surface
          style={{
            width: photoWidth,
            height: photoHeight,
            borderRadius: 5,
          }}
        >
          <ImageFilters
            {...FILTERS.find((f) => f.id === tempFilter).filter}
            width={filterWidth}
            height={filterHeight}
          >
            {{
              uri: props.image_cropped,
            }}
          </ImageFilters>
        </Surface>

`

ImageFilters fails to render base64 data uri

I'm attempting to use Expo / ImageFilters with a local image (from the camera) using a uri that looks like 'data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEA...' however it's failing with error "EXGL: Invalid pixel data argument for gl.texImage2D()!". The same code works fine with a regular uri as in the README example.

The comments in gre/gl-react#140 imply this may be an Expo issue, however I'm able to use a react-native Image component in place of ImageFilters and it works fine (so I don't think Expo is the problem).

Can ImageFilters be used with a local (in-memory) image?

My setup:
expo: ^35.0.1,
expo-camera: ~7.0.0,
expo-gl: ^8.3.1,
expo-image-manipulator: ~7.0.0,
gl-react: ^4.0.1,
gl-react-expo: ^4.0.1,
react-native-gl-image-filters: ^0.1.1,

Passing Component as children do not work

I get this error if I try to pass a component as a children

code sample


       <Surface ref={ref => (image = ref)} style={{
                    //flex: 1
                    width: Dimensions.get('window').width,
                    height: Dimensions.get('window').height * 0.7,
                    alignSelf: "center"
                    // 
                }}>
                    <ImageFilters
                        width={Dimensions.get('window').width}
                        height={Dimensions.get('window').height * 0.7}
                        {...setting}
                        style={{
                            // width: Dimensions.get('window').width * 0.75,
                            // height: Dimensions.get('window').width,
                            // alignSelf: "center"
                        }}
                    // width={Dimensions.get('window').width}
                    // height={Dimensions.get('window').height}
                    // temperature={40000}
                    // blur={30}
                    >
                            <Video
                                source={{ uri: state.path }}
                                rate={1.0}
                                volume={1.0}
                                isMuted={false}
                                shouldPlay={false}
                                useNativeControls={false}
                                isLooping
                                //  resizeMode="cover"
                                style={{ width: '100%', height: '100%' }}
                                shouldPlay
                            />


                    </ImageFilters>
                

                </Surface>

I get the error Node#420(sharpen#5, uniform t: child is not renderable. Got null)

Package.json


    "@react-native-community/datetimepicker": "2.4.0",
    "@react-native-community/masked-view": "0.1.10",
    "@react-navigation/bottom-tabs": "^5.7.2",
    "@react-navigation/drawer": "^5.8.6",
    "@react-navigation/native": "^5.7.1",
    "@react-navigation/stack": "^5.7.1",
    "buffer": "^5.4.3",
    "expo": "~38.0.8",
    "expo-av": "~8.2.1",
    "expo-camera": "^8.3.1",
    "expo-constants": "^9.1.1",
    "expo-font": "^8.2.1",
    "expo-gl": "^8.4.0",
    "expo-image-picker": "^8.4.0",
    "expo-linear-gradient": "~8.2.1",
    "expo-permissions": "^9.1.0",
    "expo-status-bar": "^1.0.2",
    "gl-react": "^4.0.1",
    "gl-react-expo": "^4.0.1",
    "moment": "^2.27.0",
    "react": "~16.11.0",
    "react-dom": "~16.11.0",
    "react-native": "https://github.com/expo/react-native/archive/sdk-38.0.2.tar.gz",
    "react-native-extra-dimensions-android": "^1.2.5",
    "react-native-gesture-handler": "~1.6.0",
    "react-native-gl-image-filters": "^0.2.2",
    "react-native-modal": "^11.5.6",
    "react-native-reanimated": "~1.9.0",
    "react-native-screens": "~2.9.0",
    "react-navigation": "^4.4.0",
    "react-navigation-drawer": "^2.5.0",
    "react-navigation-stack": "^2.8.2"

thanks

Not showing the picture

Hi,
I followed the instructions. But there is nothing shown on the screen of the simulator except the "Welcome" text and the "Save" button.
Any ideas?

Expo - Ios app is crashing

Hi.

We implemented this wonderful library in order to get a grayscale over a profile picture. This implementation worked perfectly for Android but the Ios app seems to be crashing.

Is there any support for Ios? This does not happens in development, it only occurs when the app has been build and it is going to run.

image

This is the code btw:

import React, { useContext } from 'react'
import { StyleSheet, Animated } from 'react-native'
import PropTypes from 'prop-types'
import { Surface } from 'gl-react-expo'
import ImageFilters from 'react-native-gl-image-filters'

import { userPropType } from '../../core/customPropTypes'
import { screenView, profileImageBorder } from '../../theme'
import {
  ANIMATION_DURATION, ANIMATION_TO_VALUE, IMAGE_BORDER_OFFSET_RATIO,
  IMAGE_BORDER_RATIO,
} from '../../core/constants'
import ThemeContext from '../../context/themeContext'

const getStyle = (theme) => StyleSheet.create({
  avatarAvailable: { borderWidth: 3, borderColor: theme.borderColorAvailable, zIndex: 2 },
  avatarNotAvailable: { borderWidth: 3, borderColor: theme.borderColorNotAvailable, zIndex: 2 },
  surfaceStyle: { width: IMAGE_BORDER_RATIO, height: IMAGE_BORDER_RATIO, borderRadius: IMAGE_BORDER_OFFSET_RATIO / 2 },
  viewOut: { ...screenView(7), ...profileImageBorder(theme.borderColorNotAvailable) },
  viewIn: { ...screenView(7), ...profileImageBorder(theme.borderColorAvailable) },
})

export default function Avatar({ user, grayScaleNumber, type, lastEventId }) {
  const { theme } = useContext(ThemeContext)
  const source = { uri: user.picture }
  const checkOutArrColors = [theme.borderColorAvailable, theme.borderColorNotAvailable]
  const checkInArrColors = [theme.borderColorNotAvailable, theme.borderColorAvailable]
  const colors = type !== 'checkIn' ? checkOutArrColors : checkInArrColors
  let borderColor = theme.borderColorNotAvailable
  const animation = new Animated.Value(type === 'checkOut' ? 1 : 0)

  Animated.timing(
    animation, { toValue: ANIMATION_TO_VALUE, duration: ANIMATION_DURATION },
  ).start()
  if (lastEventId !== 'fakeRecord') {
    borderColor = animation.interpolate({ inputRange: [0, 1], outputRange: colors })
  }

  const imageFiltersProps = {
    saturation: grayScaleNumber,
    width: IMAGE_BORDER_RATIO,
    height: IMAGE_BORDER_RATIO,
  }

  const avatarStyleProps = { ...(type === 'checkIn'
    ? getStyle(theme).viewIn : getStyle(theme).viewOut), ...{ borderColor },
  }

  return (
    <Animated.View style={avatarStyleProps}>
      <Surface style={getStyle(theme).surfaceStyle} >
        <ImageFilters {...imageFiltersProps}>{source}</ImageFilters>
      </Surface>
    </Animated.View>
  )
}

Avatar.propTypes = {
  user: PropTypes.shape(userPropType).isRequired,
  type: PropTypes.string,
  grayScaleNumber: PropTypes.number,
  lastEventId: PropTypes.string,
}
 

Running with expo

Maybe do I have to eject?

App crashes when trying to display filtered image from expo sdk 44

Hi Gregory!

Image filter functionality worked perfectly in my app till expo sdk 43. Thanks for that!

After upgrade to sdk 44 (and sdk45 as well) when entering screen with filtered image, app crashes and closes without any message on Expo Go and also no error message is visible on Sentry.

I think it has something to do with the fact that library or it dependencies relies on @unimodules/core, which is not available from sdk44. Are you going to upgrade your package so it functions well also on expo sdk44 and further versions.

Will be grateful for any info in that topic. I need to know if I should resign from filters functionality since I can not sustainably support it with sdk upgrades. I would love to avoid that.

Thanks in advance,
Didiwloski

gl-shader Eroor: compiling shader

Hi.
When I run the expo example and react native example on my android, I get this error:

gl-shader: Error compiling shader:
Compile failed.
ERROR: 0:1: '' : Invalid directive 2
1 compilation errors. No code generated.

Please, what is this due to?

Android 10
gl-react: 4.1.0,
gl-react-expo: 4.1.0,
expo-gl: 9.2.0,
buffer: 5.7.1
expo sdk 40 ejected

Thank you.

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.