Giter Club home page Giter Club logo

photofilters's Introduction

Photo Filters package for flutter

A flutter package for iOS and Android for applying filter to an image. A set of preset filters are also available. You can create your own filters too.

Installation

First, add photofilters and image as a dependency in your pubspec.yaml file.

iOS

No configuration required - the plugin should work out of the box.

Android

No configuration required - the plugin should work out of the box.

Example

import 'dart:async';
import 'dart:io';

import 'package:flutter/material.dart';
import 'package:path/path.dart';
import 'package:photofilters/photofilters.dart';
import 'package:image/image.dart' as imageLib;
import 'package:image_picker/image_picker.dart';

void main() => runApp(new MaterialApp(home: MyApp()));

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => new _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String fileName;
  List<Filter> filters = presetFiltersList;
  File imageFile;

  Future getImage(context) async {
    imageFile = await ImagePicker.pickImage(source: ImageSource.gallery);
    fileName = basename(imageFile.path);
    var image = imageLib.decodeImage(imageFile.readAsBytesSync());
    image = imageLib.copyResize(image, width: 600);
     Map imagefile = await Navigator.push(
      context,
      new MaterialPageRoute(
        builder: (context) => new PhotoFilterSelector(
              title: Text("Photo Filter Example"),
              image: image,
              filters: presetFiltersList,
              filename: fileName,
              loader: Center(child: CircularProgressIndicator()),
              fit: BoxFit.contain,
            ),
      ),
    );
    if (imagefile != null && imagefile.containsKey('image_filtered')) {
      setState(() {
        imageFile = imagefile['image_filtered'];
      });
      print(imageFile.path);
    }
  }

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(
        title: new Text('Photo Filter Example'),
      ),
      body: Center(
        child: new Container(
          child: imageFile == null
              ? Center(
                  child: new Text('No image selected.'),
                )
              : Image.file(imageFile),
        ),
      ),
      floatingActionButton: new FloatingActionButton(
        onPressed: () => getImage(context),
        tooltip: 'Pick Image',
        child: new Icon(Icons.add_a_photo),
      ),
    );
  }
}

UI Screen Shots

Sample Images of Filters

No Filter No Filter AddictiveBlue AddictiveBlue AddictiveRed AddictiveRed Aden Aden
Amaro Amaro Ashby Ashby Brannan Brannan Brooklyn Brooklyn
Charmes Charmes Clarendon Clarendon Crema Crema Dogpatch Dogpatch
Earlybird Earlybird 1977 1977 Gingham Gingham Ginza Ginza
Hefe Hefe Helena Helena Hudson Hudson Inkwell Inkwell
Juno Juno Kelvin Kelvin Lark Lark Lo-Fi Lo-Fi
Ludwig Ludwig Maven Maven Mayfair Mayfair Moon Moon
Nashville Nashville Perpetua Perpetua Reyes Reyes Rise Rise
Sierra Sierra Skyline Skyline Slumber Slumber Stinson Stinson
Sutro Sutro Toaster Toaster Valencia Valencia Vesper Vesper
Walden Walden Willow Willow X-Pro II X-Pro II

Sample Images of Convolution Filters

Identity Identity Emboss Emboss Sharpen Sharpen Colored Edge Detection Colored Edge Detection
Blur Blur Edge Detection Medium Edge Detection Medium Edge Detection Hard Edge Detection Hard Guassian Blur Guassian Blur
Low Pass Low Pass High Pass High Pass Mean Mean

Filters

There are two types of filters. ImageFilter and ColorFilter.

Image Filter

Image filter applies its subfilters directly to the whole image one by one. It is computationally expensive since the complexity & time increases as the number of subfilters increases.

You can create your own custom image filter as like this:

    import 'package:photofilters/filters/image_filters.dart';

    var customImageFilter = new ImageFilter(name: "Custom Image Filter");
    customImageFilter.subFilters.add(ConvolutionSubFilter.fromKernel(
      coloredEdgeDetectionKernel,
    ));
    customImageFilter.subFilters.add(ConvolutionSubFilter.fromKernel(
      gaussian7x7Kernel,
    ));
    customImageFilter.subFilters.add(ConvolutionSubFilter.fromKernel(
      sharpenKernel,
    ));
    customImageFilter.subFilters.add(ConvolutionSubFilter.fromKernel(
      highPass3x3Kernel,
    ));
    customImageFilter.subFilters.add(ConvolutionSubFilter.fromKernel(
      lowPass3x3Kernel,
    ));
    customImageFilter.subFilters.add(SaturationSubFilter(0.5));

You can also inherit the ImageFilter class to create another image filter.

class MyImageFilter extends ImageFilter {
  MyImageFilter(): super(name: "My Custom Image Filter") {
    this.addSubFilter(ConvolutionSubFilter.fromKernel(sharpenKernel));
  }
}

Color Filter

Color filter applies its subfilters to each pixel one by one. It is computationally less expensive than the ImageFilter. It will loop through the image pixels only once irrespective of the number of subfilters.

You can create your own custom color filter as like this:

    import 'package:photofilters/filters/color_filters.dart';

    var customColorFilter = new ColorFilter(name: "Custom Color Filter");
    customColorFilter.addSubFilter(SaturationSubFilter(0.5));
    customColorFilter
        .addSubFilters([BrightnessSubFilter(0.5), HueRotationSubFilter(30)]);

You can inherit the ColorFilter class too

class MyColorFilter extends ColorFilter {
  MyColorFilter() : super(name: "My Custom Color Filter") {
    this.addSubFilter(BrightnessSubFilter(0.8));
    this.addSubFilter(HueRotationSubFilter(30));
  }
}

Sub filters

There are two types of subfilters. One can be added to the ColorFilter and the other can be added to the ImageFilter. You can inherit ColorSubFilter class to implement the former and you can use the ImageSubFilter mixin to implement the latter. You can create a same subfilter that can be used for both Image and Color Filters. The BrightnessSubFilter is an example of this.

class BrightnessSubFilter extends ColorSubFilter with ImageSubFilter {
  final num brightness;
  BrightnessSubFilter(this.brightness);

  ///Apply the [BrightnessSubFilter] to an Image.
  @override
  void apply(Uint8List pixels, int width, int height) =>
      image_filter_utils.brightness(pixels, brightness);

  ///Apply the [BrightnessSubFilter] to a color.
  @override
  RGBA applyFilter(RGBA color) =>
      color_filter_utils.brightness(color, brightness);
}

Getting Started

For help getting started with Flutter, view our online documentation.

For help on editing package code, view the documentation.

photofilters's People

Contributors

chojecki avatar dhruvanbhalara avatar emiliodallatorre avatar jinosh05 avatar sharafudheen-ispg avatar shinriyo avatar skkallayath 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

photofilters's Issues

Localized filter names

Hello!
This is an amazing library, thank you.

I've noticed that there is not easy way to change (localize) the names of the filters that come with the library.
I guess easiest way would be to create an optional name parameter to the constructors of the filters.

What do you think?

Creating own camera filter

Hi, thank you for this package. It gives a lot of inspiration.

I want to create my own unique filters, are there resources that you used to learn to create this? It would be amazing if you can share it.

Cheers
Troy

Delayed while going to the PhotoFilterSelector

While running the following code onTap:

Navigator.push(
      context,
      new MaterialPageRoute(
        builder: (context) => new PhotoFilterSelector(
          //
        ),
      ),
    );

it hangs UI for some seconds then goes to the next screen. I tried to call setState before it to show a progress bar but setState was also called after the delay.

Applying filters to Bitmaps

I was just wondering if it is possible to apply filters to bitmaps as well. In our case, it is not just the gallery image, we work with bitmaps that need to be filtered. Can you help me with this?

Is this Possible with photofilters? Document clearly...

Hi,
I really thank you for your great done photofilters.

I want to make an photo which have an image of text-book more clearly.

Can I use photofilters to make this function?

If so, could you tell me some tips for this?
( for example, which method in photofilters is suitable for this job ... )

Thank you.

( I want to do like below )

image

video filters

is their any way i can use these filters in video.
if not is their any way to add filters.

Image Filter

Taking too much Time too Apply Filter on Image

when i useing camera then photofilter image rotated left side

when i using image pick from camera then photo filter image rotated left side that images for uploading and view is not correct proper view but photo pick from gallery is perfectly fine then the issues Camera is please solve my problem as soon as possible

thank you so mach for this plugin usefully my project...,

App crashes on iOS Device

Screenshot 2020-06-05 at 11 22 04 AM
The app Crashed on clicking The floating action button to select image in example project.
No error was thrown.
The complete debug console log is here:

`Launching lib/main.dart on iPhone S in debug mode...

Xcode build done. 66.6s

Connecting to VM Service at ws://127.0.0.1:52406/Nm_PiFrIudM=/ws

Lost connection to device.

Exited
(sigterm)`

Image is blurred after filtering

I noticed that the picture seems to be blurred after being filtered(include No Filter model) . How can I solve this problem, thank you ver much!

plugin not worked on ios

hi
i will use this plugin on my project on ios and android but it not worked
when i choose a photo navigator pushed to new view an a loader loops ....
please help me to use your plugin

Big File => crash app

Can you help me with one thing i don't understand how to do that.Please i am grateful to you if you help me.
when i using big image (about 10MB), my app was crashed. so i try remove decode and end code but it not work.
can you help me please?
thank you so much <3

Cast error bug thrown using recommended code

Hello!

I updated the photoFilters plugin to the latest version (currently 3.0.0 with null safety) and using the main example I am recieving this error:

The following _CastError was thrown building PhotoFilterSelector(dirty, state: _PhotoFilterSelectorState#b6edf):
type '(Map<String, dynamic>) => List?' is not a subtype of type '(Map<String, dynamic>) => FutureOr<List>' in type cast

I made some tests with other Widgets under the same circumstances and no error was thrown, I also used other widgets using the Image package. I used the code in your example:

Map imagefile = await Navigator.push(
      context,
      new MaterialPageRoute(
        builder: (context) => new PhotoFilterSelector(
              title: Text("Photo Filter Example"),
              image: image,
              filters: presetFiltersList,
              filename: fileName,
              loader: Center(child: CircularProgressIndicator()),
              fit: BoxFit.contain,
            ),
      ),
    );

Feature Request: Pass multiple images

It'd be very handy if the plugin can take multiple images so filter could be applied to them. Just swipe left or right to go to the previous or next one and just apply filter.

Is There An Exposed Method To Programmatically Create The Filtered Image

What am trying to achieve is handle several images, I have managed to get all the images in page carousel, so when you swipe left and right you see all the images along side the filters. My problem right now, all this navigation is done inside a page (stateful widget). I cant seem to find a way of getting all the filtered images so i was wondering if there is an exposed method that can be called to return the filtered image.

Blocking UI...

Hello, when I test the filter on the Android real machine, jumping to a new page will block the UI, and the new page has four large images. Causes the app to be unresponsive

The following method will block the UI. Is there any solution?

Future _getImage() async {

double imgH = (ScreenUtil().screenHeight - kToolbarHeight - 100)/2;

fileName = basename(widget.imgFile.path);

var image = imageLib.decodeImage(widget.imgFile.readAsBytesSync());
_image = imageLib.copyResize(image, -1,imgH.toInt());
setState(() {
  
});

}

Sharpen filter?

Thanks for this great plugin.
I have found the code related to sharpen filter in lib as below

ConvolutionKernel sharpenKernel =
    new ConvolutionKernel([-1, -1, -1, -1, 9, -1, -1, -1, -1]);

Can you explain how to apply it to an image?

Dependancy conflict with path_provider: ^0.5.0+1

In my project, I have to use

cached_network_image: ^0.8.0

in pubspec.yaml

This requires

path_provider: ^0.5.0+1

If I mention version 0.5.0+1 for path_provider, it results in dependancy conflict issue as PhotoFilters requires older version

path_provider: ^0.4.0

How to update photofilters to user latest path_provider version?

make api use a Uint8List instead of imageLib.Image

Uint8List is more universal as a type in dart. If I'm using an image elsewhere that I'd like to use with this package, I'm most likely using it as a File or Uint8List, not an imageLib.Image. As this package is currently written I would have to convert the image to apply a filter, then convert back if I want to use the result somewhere, which isn't clean.

Optimisations

Hey, this is a great package however it regularly crashes my development enviroment and also sometimes crashed on my pixel 3 device. I think it's because it's applying each filter to the full sized image every time. I notice in your example you resize the image to 600 however i need a higher quality version for my app.

Could it generate thumbnails using a much smaller version of the source image and then when the user selects a filter apply that one on the full sized image? I think it would make the whole thing much more stable and feel more responsive.

Issue of getting filtered image

Can you help me with one thing i don't understand how to do that.Please i am grateful to you if you help me.
PhotoFilter _photoFilter;
Filter _filter = presetFiltersList[23];
_photoFilter = new PhotoFilter(
image: image,
filename: fileName,
filter: _filter,
fit: BoxFit.fill,
);
After doing that I need the filtered image.
Uint32List _uint32list = _photoFilter.image.data;
Uint8List byte_data= _uint32list.buffer.asUint8List(); i did that process to get the filtered image.but could not. wheni try to read the filtered image in Image.memory(byte_data);
showing that "Exception: Invalid image data"
can you help me please ?

type `'(Map<String, dynamic>) => List<int>?'` is not a subtype of type `'(Map<String, dynamic>)`

Hi, I am using the develop branch and getting this issue. I know the fact that the branch is completely not converted to null-safety version yet. You can ignore if you already know about it.

════════ Exception caught by widgets library ═══════════════════════════════════
The following _CastError was thrown building PhotoFilterSelector(dirty, state: _PhotoFilterSelectorState#28488):
type '(Map<String, dynamic>) => List<int>?' is not a subtype of type '(Map<String, dynamic>) => FutureOr<List<int>>' in type cast

The relevant error-causing widget was
PhotoFilterSelector
When the exception was thrown, this was the stack
#0      _PhotoFilterSelectorState._buildFilteredImage
#1      _PhotoFilterSelectorState.build
#2      StatefulElement.build
#3      ComponentElement.performRebuild
#4      StatefulElement.performRebuild
...
════════════════════════════════════════════════════════════════════════════════

The error points here

	Widget _buildFilteredImage(
      Filter? filter, imageLib.Image? image, String? filename) {
    if (cachedFilters[filter?.name ?? "_"] == null) {
      return FutureBuilder<List<int>>(
        future: compute(
            applyFilter as FutureOr<List<int>> Function(Map<String, dynamic>),   <-------- HERE
            <String, dynamic>{
              "filter": filter,
              "image": image,
              "filename": filename,
            }),
        builder: (BuildContext context, AsyncSnapshot<List<int>> snapshot) {
          switch (snapshot.connectionState) {
            case ConnectionState.none:
              return widget.loader;
            case ConnectionState.active:
            case ConnectionState.waiting:
              return widget.loader;
            case ConnectionState.done:
              if (snapshot.hasError)
                return Center(child: Text('Error: ${snapshot.error}'));
              cachedFilters[filter?.name ?? "_"] = snapshot.data;
              return widget.circleShape
                  ? SizedBox(
                      height: MediaQuery.of(context).size.width / 3,
                      width: MediaQuery.of(context).size.width / 3,
                      child: Center(
                        child: CircleAvatar(
                          radius: MediaQuery.of(context).size.width / 3,
                          backgroundImage: MemoryImage(
                            snapshot.data as dynamic,
                          ),
                        ),
                      ),
                    )
                  : Image.memory(
                      snapshot.data as dynamic,
                      fit: BoxFit.contain,
                    );
          }
          // unreachable
        },
      );
    } else {
      return widget.circleShape
          ? SizedBox(
              height: MediaQuery.of(context).size.width / 3,
              width: MediaQuery.of(context).size.width / 3,
              child: Center(
                child: CircleAvatar(
                  radius: MediaQuery.of(context).size.width / 3,
                  backgroundImage: MemoryImage(
                    cachedFilters[filter?.name ?? "_"] as dynamic,
                  ),
                ),
              ),
            )
          : Image.memory(
              cachedFilters[filter?.name ?? "_"] as dynamic,
              fit: widget.fit,
            );
    }
  }
}

Can't apply a photo filter successfully

import 'package:image/image.dart' as v3;
import 'package:photofilters/photofilters.dart';
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:multi_image_picker/multi_image_picker.dart';
import 'dart:typed_data';

Future grayScaleImage(Asset asset) async {
ByteData bd = await asset.requestOriginal();
var x = v3.Image.fromBytes(asset.originalWidth, asset.originalHeight, bd.buffer.asUint8List(), format: v3.Format.rgba);
return PhotoFilter(
image: x,
filename: null,
filter: AddictiveRedFilter())
.loader;}

FutureBuilder(
future: grayScaleImage(images[0]), //grayImages(images)
builder: (BuildContext context, AsyncSnapshot snapshot) {
//snapshot is the list of grayImages
if (snapshot.hasData) {
if (snapshot.data.isEmpty) {
return Container(
child: Center(child: Text("Loading...")),
color: Colors.blue);
} else {
return Expanded(
child: ListView.builder(
itemCount: snapshot.data.length,
itemBuilder: (BuildContext context, int index) {
return snapshot.data[
index]; // this should be changed to display the images
},
), // ListView.builder)
);
}
} else {
return new Container();
}
// else statement
},
),

I'm getting the images by converting assets (obtained using MultiImagePicker) to byte data and then converting it to the type Image from the class Image/Image.dart (named "v3" here) and then I'm trying to apply a filter using this library and return a widget that displays the edited image but I can't do that (I use a FutureBuilder to try to eventually use the returned widget that displays the edited image). I get an error during compilation: (params["image"] = imageLib.copyResize(params["image"], width)). Any idea how I can resolve this? Basically, I think something goes wrong when the copyResize function is called when the PhotoFilter function is called I guess.

License?

Hi!

I see the license is missing in this project, is that on purpose? Thanks!

app crashes by [Exhausted heap space] [Out of memory]

This error causes when using examples shown on package.
this is on Android Emulator for now.
not checked on Android Device / iOS Emulator / iOS Device

D/SharedPreferencesImpl( 1733): Time required to fsync /data/user/0/com.example.examples/shared_prefs/flutter_image_picker_shared_preference.xml: [<1: 0, <2: 0, <4: 0, <8: 0, <16: 0, <32: 0, <64: 0, <128: 0, <256: 0, <512: 0, <1024: 1, <2048: 0, <4096: 0, <8192: 0, <16384: 0, >=16384: 0]
E/DartVM  ( 1733): Exhausted heap space, trying to allocate 32 bytes.
E/DartVM  ( 1733): Exhausted heap space, trying to allocate 663568 bytes.
E/flutter ( 1733): [ERROR:flutter/shell/common/shell.cc(93)] Dart Error: Out of memory
E/flutter ( 1733): [ERROR:flutter/runtime/dart_isolate.cc(983)] CreateDartIsolateGroup failed: 0xaeba3fdc
E/DartVM  ( 1733): Exhausted heap space, trying to allocate 112 bytes.
E/Dart    ( 1733): ../../third_party/dart/runtime/vm/object.cc: 2691: error: Out of memory.
E/DartVM  ( 1733): version=2.14.0 (stable) (Mon Sep 6 13:47:59 2021 +0200) on "android_ia32"
E/DartVM  ( 1733): pid=1733, thread=1863, isolate_group=_spawn(0xf3c108a0), isolate=_spawn(0xf3b2b810)
E/DartVM  ( 1733): isolate_instructions=c44db820, vm_instructions=c44db820
E/DartVM  ( 1733):   pc 0xc4617bbb fp 0xaeba2ff8 /data/app/~~1BQysAIAStSmQ7s-vbSM1Q==/com.example.examples-tsXmUnS2bzwGdKswNBHrfw==/lib/x86/libflutter.so+0x19d5bbb
E/DartVM  ( 1733):   pc 0xc488dbc1 fp 0xaeba3018 /data/app/~~1BQysAIAStSmQ7s-vbSM1Q==/com.example.examples-tsXmUnS2bzwGdKswNBHrfw==/lib/x86/libflutter.so+0x1c4bbc1
E/DartVM  ( 1733):   pc 0xc44db9c6 fp 0xaeba3048 /data/app/~~1BQysAIAStSmQ7s-vbSM1Q==/com.example.examples-tsXmUnS2bzwGdKswNBHrfw==/lib/x86/libflutter.so+0x18999c6
E/DartVM  ( 1733):   pc 0xc459d7fb fp 0xaeba30a8 /data/app/~~1BQysAIAStSmQ7s-vbSM1Q==/com.example.examples-tsXmUnS2bzwGdKswNBHrfw==/lib/x86/libflutter.so+0x195b7fb
E/DartVM  ( 1733):   pc 0xc458ceda fp 0xaeba30f8 /data/app/~~1BQysAIAStSmQ7s-vbSM1Q==/com.example.examples-tsXmUnS2bzwGdKswNBHrfw==/lib/x86/libflutter.so+0x194aeda
E/DartVM  ( 1733):   pc 0xc4591be8 fp 0xaeba3998 /data/app/~~1BQysAIAStSmQ7s-vbSM1Q==/com.example.examples-tsXmUnS2bzwGdKswNBHrfw==/lib/x86/libflutter.so+0x194fbe8
E/DartVM  ( 1733):   pc 0xc45236d5 fp 0xaeba3a58 /data/app/~~1BQysAIAStSmQ7s-vbSM1Q==/com.example.examples-tsXmUnS2bzwGdKswNBHrfw==/lib/x86/libflutter.so+0x18e16d5
E/DartVM  ( 1733):   pc 0xc4523ccd fp 0xaeba3b28 /data/app/~~1BQysAIAStSmQ7s-vbSM1Q==/com.example.examples-tsXmUnS2bzwGdKswNBHrfw==/lib/x86/libflutter.so+0x18e1ccd
E/DartVM  ( 1733):   pc 0xc4874c5e fp 0xaeba3ba8 /data/app/~~1BQysAIAStSmQ7s-vbSM1Q==/com.example.examples-tsXmUnS2bzwGdKswNBHrfw==/lib/x86/libflutter.so+0x1c32c5e
E/DartVM  ( 1733):   pc 0xc4874fc7 fp 0xaeba3c48 /data/app/~~1BQysAIAStSmQ7s-vbSM1Q==/com.example.examples-tsXmUnS2bzwGdKswNBHrfw==/lib/x86/libflutter.so+0x1c32fc7
E/DartVM  ( 1733):   pc 0xc402e786 fp 0xaeba3cb8 /data/app/~~1BQysAIAStSmQ7s-vbSM1Q==/com.example.examples-tsXmUnS2bzwGdKswNBHrfw==/lib/x86/libflutter.so+0x13ec786
E/DartVM  ( 1733):   pc 0xc402f7a7 fp 0xaeba3cf8 /data/app/~~1BQysAIAStSmQ7s-vbSM1Q==/com.example.examples-tsXmUnS2bzwGdKswNBHrfw==/lib/x86/libflutter.so+0x13ed7a7
E/DartVM  ( 1733):   pc 0xc402dbc7 fp 0xaeba3d28 /data/app/~~1BQysAIAStSmQ7s-vbSM1Q==/com.example.examples-tsXmUnS2bzwGdKswNBHrfw==/lib/x86/libflutter.so+0x13ebbc7
E/DartVM  ( 1733):   pc 0xc402baf3 fp 0xaeba3d98 /data/app/~~1BQysAIAStSmQ7s-vbSM1Q==/com.example.examples-tsXmUnS2bzwGdKswNBHrfw==/lib/x86/libflutter.so+0x13e9af3
E/DartVM  ( 1733):   pc 0xc402d721 fp 0xaeba3fa8 /data/app/~~1BQysAIAStSmQ7s-vbSM1Q==/com.example.examples-tsXmUnS2bzwGdKswNBHrfw==/lib/x86/libflutter.so+0x13eb721
E/DartVM  ( 1733):   pc 0xc44f09ec fp 0xaeba4028 /data/app/~~1BQysAIAStSmQ7s-vbSM1Q==/com.example.examples-tsXmUnS2bzwGdKswNBHrfw==/lib/x86/libflutter.so+0x18ae9ec
E/DartVM  ( 1733):   pc 0xc44f0968 fp 0xaeba4048 /data/app/~~1BQysAIAStSmQ7s-vbSM1Q==/com.example.examples-tsXmUnS2bzwGdKswNBHrfw==/lib/x86/libflutter.so+0x18ae968
E/DartVM  ( 1733):   pc 0xc468e08c fp 0xaeba40e8 /data/app/~~1BQysAIAStSmQ7s-vbSM1Q==/com.example.examples-tsXmUnS2bzwGdKswNBHrfw==/lib/x86/libflutter.so+0x1a4c08c
E/DartVM  ( 1733):   pc 0xc468e33a fp 0xaeba4118 /data/app/~~1BQysAIAStSmQ7s-vbSM1Q==/com.example.examples-tsXmUnS2bzwGdKswNBHrfw==/lib/x86/libflutter.so+0x1a4c33a
E/DartVM  ( 1733):   pc 0xc4613102 fp 0xaeba4178 /data/app/~~1BQysAIAStSmQ7s-vbSM1Q==/com.example.examples-tsXmUnS2bzwGdKswNBHrfw==/lib/x86/libflutter.so+0x19d1102
E/DartVM  ( 1733):   pc 0xf09a6f55 fp 0xaeba4198 /apex/com.android.runtime/lib/bionic/libc.so+0xe6f55
E/DartVM  ( 1733):   pc 0xf0938868 fp 0xaeba41c8 /apex/com.android.runtime/lib/bionic/libc.so+0x78868
E/DartVM  ( 1733): -- End of DumpStackTrace
F/libc    ( 1733): Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 1863 (DartWorker), pid 1733 (xample.examples)
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
Build fingerprint: 'google/sdk_gphone_x86/generic_x86_arm:10/RPP4.200409.015/6455311:user/release-keys'
Revision: '0'
ABI: 'x86'
Timestamp: 2021-09-17 07:34:38+0000
pid: 1733, tid: 1863, name: DartWorker  >>> com.example.examples <<<
uid: 10149
signal 6 (SIGABRT), code -1 (SI_QUEUE), fault addr --------
Abort message: '../../third_party/dart/runtime/vm/object.cc: 2691: error: Out of memory.'
    eax 00000000  ebx 000006c5  ecx 00000747  edx 00000006
    edi f098ceae  esi aeba2f88
    ebp f41b9b30  esp aeba2f08  eip f41b9b39
backtrace:
      #00 pc 00000b39  [vdso] (__kernel_vsyscall+9)
      #01 pc 0005b058  /apex/com.android.runtime/lib/bionic/libc.so (syscall+40) (BuildId: f93c954efc24b8a2e43bc3d969ca228c)
      #02 pc 00076833  /apex/com.android.runtime/lib/bionic/libc.so (abort+195) (BuildId: f93c954efc24b8a2e43bc3d969ca228c)
      #03 pc 018999d2  /data/app/~~1BQysAIAStSmQ7s-vbSM1Q==/com.example.examples-tsXmUnS2bzwGdKswNBHrfw==/lib/x86/libflutter.so (BuildId: 66ec0293d80823bf6820a692601e59ed30c0d039)
      #04 pc 0195b7fa  /data/app/~~1BQysAIAStSmQ7s-vbSM1Q==/com.example.examples-tsXmUnS2bzwGdKswNBHrfw==/lib/x86/libflutter.so (BuildId: 66ec0293d80823bf6820a692601e59ed30c0d039)
      #05 pc 0194aed9  /data/app/~~1BQysAIAStSmQ7s-vbSM1Q==/com.example.examples-tsXmUnS2bzwGdKswNBHrfw==/lib/x86/libflutter.so (BuildId: 66ec0293d80823bf6820a692601e59ed30c0d039)
      #06 pc 0194fbe7  /data/app/~~1BQysAIAStSmQ7s-vbSM1Q==/com.example.examples-tsXmUnS2bzwGdKswNBHrfw==/lib/x86/libflutter.so (BuildId: 66ec0293d80823bf6820a692601e59ed30c0d039)
      #07 pc 018e16d4  /data/app/~~1BQysAIAStSmQ7s-vbSM1Q==/com.example.examples-tsXmUnS2bzwGdKswNBHrfw==/lib/x86/libflutter.so (BuildId: 66ec0293d80823bf6820a692601e59ed30c0d039)
      #08 pc 018e1ccc  /data/app/~~1BQysAIAStSmQ7s-vbSM1Q==/com.example.examples-tsXmUnS2bzwGdKswNBHrfw==/lib/x86/libflutter.so (BuildId: 66ec0293d80823bf6820a692601e59ed30c0d039)
      #09 pc 01c32c5d  /data/app/~~1BQysAIAStSmQ7s-vbSM1Q==/com.example.examples-tsXmUnS2bzwGdKswNBHrfw==/lib/x86/libflutter.so (BuildId: 66ec0293d80823bf6820a692601e59ed30c0d039)
      #10 pc 01c32fc6  /data/app/~~1BQysAIAStSmQ7s-vbSM1Q==/com.example.examples-tsXmUnS2bzwGdKswNBHrfw==/lib/x86/libflutter.so (BuildId: 66ec0293d80823bf6820a692601e59ed30c0d039)
      #11 pc 013ec785  /data/app/~~1BQysAIAStSmQ7s-vbSM1Q==/com.example.examples-tsXmUnS2bzwGdKswNBHrfw==/lib/x86/libflutter.so (BuildId: 66ec0293d80823bf6820a692601e59ed30c0d039)
      #12 pc 013ed7a6  /data/app/~~1BQysAIAStSmQ7s-vbSM1Q==/com.example.examples-tsXmUnS2bzwGdKswNBHrfw==/lib/x86/libflutter.so (BuildId: 66ec0293d80823bf6820a692601e59ed30c0d039)
      #13 pc 013ebbc6  /data/app/~~1BQysAIAStSmQ7s-vbSM1Q==/com.example.examples-tsXmUnS2bzwGdKswNBHrfw==/lib/x86/libflutter.so (BuildId: 66ec0293d80823bf6820a692601e59ed30c0d039)
      #14 pc 013e9af2  /data/app/~~1BQysAIAStSmQ7s-vbSM1Q==/com.example.examples-tsXmUnS2bzwGdKswNBHrfw==/lib/x86/libflutter.so (BuildId: 66ec0293d80823bf6820a692601e59ed30c0d039)
      #15 pc 013eb720  /data/app/~~1BQysAIAStSmQ7s-vbSM1Q==/com.example.examples-tsXmUnS2bzwGdKswNBHrfw==/lib/x86/libflutter.so (BuildId: 66ec0293d80823bf6820a692601e59ed30c0d039)
      #16 pc 018ae9eb  /data/app/~~1BQysAIAStSmQ7s-vbSM1Q==/com.example.examples-tsXmUnS2bzwGdKswNBHrfw==/lib/x86/libflutter.so (BuildId: 66ec0293d80823bf6820a692601e59ed30c0d039)
      #17 pc 018ae967  /data/app/~~1BQysAIAStSmQ7s-vbSM1Q==/com.example.examples-tsXmUnS2bzwGdKswNBHrfw==/lib/x86/libflutter.so (BuildId: 66ec0293d80823bf6820a692601e59ed30c0d039)
      #18 pc 01a4c08b  /data/app/~~1BQysAIAStSmQ7s-vbSM1Q==/com.example.examples-tsXmUnS2bzwGdKswNBHrfw==/lib/x86/libflutter.so (BuildId: 66ec0293d80823bf6820a692601e59ed30c0d039)
      #19 pc 01a4c339  /data/app/~~1BQysAIAStSmQ7s-vbSM1Q==/com.example.examples-tsXmUnS2bzwGdKswNBHrfw==/lib/x86/libflutter.so (BuildId: 66ec0293d80823bf6820a692601e59ed30c0d039)
      #20 pc 019d1101  /data/app/~~1BQysAIAStSmQ7s-vbSM1Q==/com.example.examples-tsXmUnS2bzwGdKswNBHrfw==/lib/x86/libflutter.so (BuildId: 66ec0293d80823bf6820a692601e59ed30c0d039)
      #21 pc 000e6f54  /apex/com.android.runtime/lib/bionic/libc.so (__pthread_start(void*)+100) (BuildId: f93c954efc24b8a2e43bc3d969ca228c)
      #22 pc 00078867  /apex/com.android.runtime/lib/bionic/libc.so (__start_thread+71) (BuildId: f93c954efc24b8a2e43bc3d969ca228c)
Lost connection to device.

flutter doctor -v

[√] Flutter (Channel stable, 2.5.0, on Microsoft Windows [Version 10.0.19043.1165], locale ja-JP)
    • Flutter version 2.5.0 at C:\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 4cc385b4b8 (9 days ago), 2021-09-07 23:01:49 -0700
    • Engine revision f0826da7ef
    • Dart version 2.14.0

[√] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    • Android SDK at C:\Users\kkane\AppData\Local\Android\Sdk
    • Platform android-30, build-tools 30.0.2
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe

[√] Android Studio (version 2020.3)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)

[√] VS Code (version 1.60.1)
    • VS Code at C:\Users\kkane\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.26.0

[√] Connected device (4 available)
    • 701SO (mobile)          • BH902QFS9A    • android-arm64  • Android 9 (API 28)
    • sdk gphone x86 (mobile) • emulator-5554 • android-x86    • Android 10 (API 29) (emulator)
    • Chrome (web)            • chrome        • web-javascript • Google Chrome 93.0.4577.82
    • Edge (web)              • edge          • web-javascript • Microsoft Edge 93.0.961.47

• No issues found!

FileSystemException when clicking check mark icon

After selecting a filter and clicking the checkmark, the saveFilteredImage() method is throwing an exception and highlighting line 240:

message: "Cannot open file"
osError: OSError (Os Error: No such file or directory)
runtimeType: Type (FileSystemException)

I believe I have the correct implementation. This is how I'm routing to the photofilters widget.
But I don't know if this is where the issue is since it breaks before popping back to my previous page.

I could really use some help with this right now! 🙏🙏🙏

_navigateAndDisplayImageEditor(
      BuildContext context, String filePath, File file, int index) async {
    final result = await Navigator.push(
      context,
      MaterialPageRoute(
        builder: (context) =>
            PhotoFiltersScreen(filePath: filePath, file: file),
      ),
    );

    setState(() {
      _selection = result;
    });

    if(_selection != null) {
      getImage(index, _selection['image_filtered']);
    }
  }



Need Null-safety migration

Hello there, my project is built with Flutter 2.0. I want to use this plugin, but it hasn't been migrated to null-safety yet, can you migrate it ASAP.

Filter from File & return File

Hi,

I am using https://pub.dev/packages/multi_image_picker/ to transform List<Asset> to List<File>
This list is generated as below :

final temp = await Directory.systemTemp.createTemp();
List<File> images = List<File>();
 for (int i = 0; i < assets.length; i++) {
    final data = await assets[i].getByteData();
    images.add(await File('${temp.path}/img$i').writeAsBytes(
      data.buffer.asUint8List(
        data.offsetInBytes, data.lengthInBytes)));
}

From that list, I then display the pictures in a carousel allowing the user to crop the picture and/or apply a filter.

I am struggling to setup the filter example.

I woud like to get the File > apply the filter > replace the previous File with the new one and then setState to update the carousel image.

Where are my mistakes there please ?

  Future<File> applyFilterOnImageFileSaveToFile(Filter filter, File src) async {
    imageLib.Image image = imageLib.decodeImage(src.readAsBytesSync());
    var pixels = image.getBytes();
    filter.apply(pixels, image.width, image.height);
    imageLib.Image out =
        imageLib.Image.fromBytes(image.width, image.height, pixels);
    File destinationFile = new File(src.path)..createSync(recursive: true);
    File(destinationFile.path).writeAsBytesSync(out.getBytes());
    return destinationFile;
  }

GestureDetector(
                       onTap: () async {
                          File newFileWithFilterApplied = await applyFilterOnImageFileSaveToFile(AddictiveRedFilter(), imagesFromMultiPickerReadyForCropping[indexCurrentPhotoCarouselIndex - 1]);
                          setState(() {
                            imagesFromMultiPickerReadyForCropping[indexCurrentPhotoCarouselIndex - 1] = newFileWithFilterApplied;
                          });
                        },
                        },
                      ),

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.