Sunday, October 2, 2022

photofilters library for flutter

There are many flutter libraries are available for download for image manipulation utility such as applying effects ,creating image animation and creating video from image etc. .Today we are share a library called @photofilters which is do exactly same as adding effects to image. Using this library we can able to manipulate image operations easy and simple way. This Package is available for both android and iOS devices.@photofilters contain set of predefined filers so we can call this methods directly into image to apply effects to image ,also you can create your own filters too.

No extra configuration required for iOS and Android this plugin work out of box

Installation

Add photofilters and image as a dependency in your pubspec.yaml file.

Sample Code

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> {
  imageLib.Image _image;
  String fileName;
  Filter _filter;
  List<Filter> filters = presetFitersList;

  Future getImage() async {
    var imageFile = await ImagePicker.pickImage(source: ImageSource.gallery);
    fileName = basename(imageFile.path);
    var image = imageLib.decodeImage(imageFile.readAsBytesSync());
    image = imageLib.copyResize(image, 600);
    setState(() {
      _image = image;
    });
  }

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(
        title: new Text('Photo Filter Example-bestflutterpack.com'),
      ),
      body: new Container(
        alignment: Alignment(0.0, 0.0),
        child: _image == null
            ? new Text('Please select a Image.')
            : new PhotoFilterSelector(
                image: _image,
                filters: presetFitersList,
                filename: fileName,
                loader: Center(child: CircularProgressIndicator()),
              ),
      ),
      floatingActionButton: new FloatingActionButton(
        onPressed: getImage,
        tooltip: 'Select a Image',
        child: new Icon(Icons.add_a_photo),
      ),
    );
  }
}

UI Screen Shots

Sample Images of Filters

 No Filter AddictiveBlue AddictiveRed
 Amaro Ashby Brannan
 Charmes Clarendon Crema
 Earlybird 1977 Gingham
 Hefe Helena Hudson
 Juno Kelvin Lark
 Ludwig Maven Mayfair
 Nashville Perpetua Reyes
 Sierra Skyline Slumber
 Sutro Toaster Valencia
 Walden Willow X-Pro II