Skip to content

About

Pure-Dart image resizer, EXIF orientation fixer, high-contrast receipt/document filter, and AI token-saver Base64 compressor for Flutter.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

Repository files navigation

smart_image_prep_kit

Pure-Dart image preparation kit for Flutter — resize, EXIF orientation fix, high-contrast B&W document/prescription scan filter, and an AI token-saver JPEG/Base64 compressor (EN + বাংলা):

  • Three tuned presets — aiFast (1280px, q78 — cheapest for AI vision calls), documentBw (1600px grayscale + contrast boost for prescriptions/documents), highQuality (2048px, q88 for print/share)
  • EXIF orientation baked in — camera photos never arrive sideways
  • AI cost telemetry — savedPercent and estimatedVisionTokens (~258/tile) tell you exactly what a vision API call will cost before you send it
  • toBase64() / toDataUri() — ready for any multimodal LLM request body, no extra glue
  • Material 3 widgets included — ImagePrepModeSelector segmented picker and ImagePrepStatsBadge, both with built-in English / বাংলা strings (ImagePrepStrings.bn())
  • Pure Dart engine — no platform channels; works in isolates, tests, and on every platform

Install

dependencies:
  smart_image_prep_kit:
    git:
      url: https://github.com/Keshab1997/smart_image_prep_kit.git
      ref: main

Quick Start

import 'package:smart_image_prep_kit/smart_image_prep_kit.dart';

// 1) Shrink a camera photo before an AI vision call:
final result = SmartImagePreprocessor.prepareBytes(
  rawBytes,                            // Uint8List from camera / file picker
  preset: ImagePrepPreset.aiFast,      // or .documentBw / .highQuality
);

print('Saved ${result.savedPercent.round()}%');
print('≈${result.estimatedVisionTokens} vision tokens');

// 2) Send straight to a multimodal API:
final dataUri = result.toDataUri();    // data:image/jpeg;base64,...

// 3) Let the user pick the mode (EN or বাংলা UI):
ImagePrepModeSelector(
  selected: mode,
  onChanged: (m) => setState(() => mode = m),
  strings: const ImagePrepStrings.bn(),
);

// 4) Show the compression result:
ImagePrepStatsBadge(result: result);

Presets

Preset Max side JPEG q B&W filter Use for
ImagePrepPreset.aiFast 1280 px 78 — cheapest AI vision/OCR calls
ImagePrepPreset.documentBw 1600 px 82 grayscale + contrast 1.42 prescriptions, printed documents
ImagePrepPreset.highQuality 2048 px 88 — printing, sharing

Custom preset: ImagePrepPreset(mode: ..., maxDimension: ..., jpegQuality: ..., documentHighContrast: ...).

API

Symbol What it does
SmartImagePreprocessor.prepareBytes(bytes, preset:) decode → bake EXIF → resize → (optional B&W) → JPEG encode
PreparedImageResult bytes, width, height, savedPercent, estimatedVisionTokens, toBase64(), toDataUri()
ImagePrepModeSelector Material 3 SegmentedButton over the three modes
ImagePrepStatsBadge compact "size • saved % • est. tokens" chip
ImagePrepStrings / ImagePrepStrings.bn() all UI labels, English / বাংলা

Throws FormatException on unsupported or corrupted image bytes — catch it around user-picked files.

About

Pure-Dart image resizer, EXIF orientation fixer, high-contrast receipt/document filter, and AI token-saver Base64 compressor for Flutter.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages