Skip to content

vicajilau/unback

Repository files navigation

Unback: Background Remover

Background Remover Logo

CI/CD Status

The open-source companion for all your image processing needs in Flutter.

Background Remover automatically extracts subjects and generates transparent backgrounds. Instead of relying on restrictive paid tools, you can process your images directly using this robust, cross-platform application.


🚀 Key Features

  • Zero-Cost Processing: Completely free and open-source. No subscriptions or hidden API limits.
  • Instant Background Removal: Select an image and let the application cleanly separate the foreground subject from the background.
  • Cross-Platform Support: Fully developed in Flutter, ensuring a smooth, native-like experience across different operating systems.
  • Privacy First: Process images securely without necessarily sending your personal photos to third-party cloud servers.

⚙️ How It Works & Architecture

To achieve smooth, high-performance background removal without freezing the user interface (UI), the application implements a dual-architecture image processing pipeline using conditional compilation:

graph TD
    A[Image Input] --> B{Platform?}
    B -- Native (iOS/Android/Desktop) --> C[Isolate-based Processor]
    C --> C1["compute() with package:image"]
    C1 --> C2[Background Isolate Thread]
    C2 --> C3[RGB Distance + Smooth Gradient Filter]
    C3 --> F[Processed PNG bytes]
    
    B -- Web --> D[Browser Canvas Processor]
    D --> D1["package:web + JS Interop"]
    D1 --> D2["Browser GPU/C++ Decoding (ImageElement)"]
    D2 --> D3[In-place Typed Array Pixel Processing]
    D3 --> D4["canvas.toBlob() (Async Browser compression)"]
    D4 --> F
Loading

📱 Native Platforms (iOS, Android & Desktop)

For native platforms, CPU-bound image operations are executed on background threads:

  • Background Isolates: The app uses Flutter's compute utility to decode the image and apply the background removal filters on a separate native thread (Isolate).
  • Pure Dart Processing: The pixels are evaluated and modified using the image package in pure Dart, ensuring consistent result accuracy across all operating systems.
  • Responsive UI: Because the heavy computing is offloaded from the main UI thread, animations and transitions remain completely fluid (60fps/120fps).

🌐 Web Platform

Since browser JavaScript runs in a single-threaded environment, standard compute runs synchronously on the main thread, which can easily freeze the browser UI. To solve this, a specialized web processor is loaded conditionally:

  • Native Browser Decoder: We decode the uploaded image using the browser's hardware-accelerated HTMLImageElement in milliseconds.
  • Canvas Pixel Manipulation: The decoded pixels are drawn to an off-screen HTMLCanvasElement. The app processes the pixels in-place inside the browser's optimized memory using a Dart Uint8ClampedList view of the JS typed array (JSUint8ClampedArray).
  • Asynchronous PNG Compression: Rather than performing slow Dart-based PNG compression, we offload PNG creation back to the browser using the asynchronous canvas.toBlob(...) API. The browser compresses the image in its internal C++ thread pool, keeping the main tab responsive and resulting in near-instant processing.

✨ The User Experience (UX)

  1. Simple Selection: Choose any photo from your device's gallery or take a new one directly from the app.
  2. Auto-Discovery: The app's processing engine automatically identifies the main subject of your image.
  3. Seamless Export: Save the resulting transparent PNG directly to your local storage or share it with other applications.

📁 Project Structure

This repository is structured as a standard Flutter application.

Directory Description
lib The core Dart code and UI components of the application.
assets Static resources, including placeholder images and icons.
android / ios Native platform configurations and bindings.

🛠️ Getting Started

Prerequisites

Ensure you have the latest stable Flutter SDK installed on your machine.

Setup the Workspace

Clone the repository and resolve dependencies:

git clone [https://github.com/vicajilau/unback.git](https://github.com/vicajilau/unback.git)
cd unback

# Fetch dependencies
flutter pub get

Running the Application

To launch the app on your connected device or emulator, run:

flutter run

📖 Usage Example

Since this is a client-facing application rather than a library, usage is entirely through the graphical interface:

  1. Launch the app on your preferred device.
  2. Tap the "Upload Image" or "Camera" button.
  3. Wait for the processing to complete.
  4. Tap "Save" to download the isolated subject to your gallery.

If you wish to integrate the underlying background removal logic into your own code, check the core processing services located within the lib/services/ directory.


📄 License

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.

Copyright (C) 2026 Víctor Carreras

About

An open-source application built with Flutter to remove image backgrounds quickly and easily.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Contributors