image_white_background 0.1.1 copy "image_white_background: ^0.1.1" to clipboard
image_white_background: ^0.1.1 copied to clipboard

Composite a transparent image onto a solid (white) background with optional padding or a fixed canvas size. Handy before sending images to OCR / vision models that prefer an opaque background.

đŸ–ŧī¸ image_white_background #

Composite a transparent image onto a solid background #

Useful before sending images to OCR / vision models, which often read more reliably against an opaque background than a transparent one.

pub package pub points likes CI license: MIT


Features #

  • 🧱 Padding mode — image plus a coloured border on every side
  • đŸŽ¯ Fixed-canvas mode — center the image on a canvas of an exact size
  • 🎨 Any background colour (defaults to white)
  • đŸ–ŧī¸ Returns PNG bytes (Uint8List) ready to upload or display
  • đŸĒļ Tiny, dart:ui-only

Install #

dependencies:
  image_white_background: ^0.1.1

or flutter pub add image_white_background.

Usage #

import 'package:image_white_background/image_white_background.dart';

// Padding mode: image + a white border on every side.
final padded = await ImageWhiteBackground.apply(
  pngBytes,
  padding: const EdgeInsets.all(24),
);

// Fixed-canvas mode: center the image on a white canvas of an exact size.
final framed = await ImageWhiteBackground.apply(
  pngBytes,
  canvasSize: const Size(1024, 1024),
);

// Any background colour you like.
final onBlack = await ImageWhiteBackground.apply(
  pngBytes,
  background: const Color(0xFF000000),
);

apply returns PNG bytes you can upload, display with Image.memory, or hand to a vision API.

Part of the Flutter Grading Toolkit — pairs with handwriting_answer_pad (capture) and ai_rubric_grader (grade).

Contributing #

Issues and PRs welcome. Run flutter test before submitting.

License #

MIT Š 2026 Muhammad Ali

0
likes
150
points
7
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Composite a transparent image onto a solid (white) background with optional padding or a fixed canvas size. Handy before sending images to OCR / vision models that prefer an opaque background.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

flutter

More

Packages that depend on image_white_background