image_whisperer 0.11.0

  • Readme
  • Changelog
  • Installing
  • 68

image_whisperer #

Rotate and resize images before uploading as necessary.

Rotates the image according to the EXIF information so the image will look normal after reencoding or when they are displayed on a canvas.

Also images can be resized by specifying maximum width/height/pixels (as in maximum number of megapixels, but without the mega prefix).

Usage #

Two types of images are used and supported: BlobImage and CanvasImage. BlobImage contains a dart:html Blob with the image data (image file contents), CanvasImage contains a CanvasElement with the image itself.

ImageProcessingPipeline pipeline = new ImageProcessingPipeline();
// The current version of the pipeline returns a BlobImage no matter what.
// Sets the output format to JPEG and the quality to 75.
pipeline.requireBlob("image/jpeg", quality: 75);
// The result should contain no more than 4096 pixels (which makes it quite small)
pipeline.maxPixels = 4096;
// Let's assume there's a `<input type="file"/>` field in the DOM and happens to
// have a nonempty value
FileUploadInputElement input = querySelector("input[type=file]");
File file = input.files.first;
BlobImage image = new BlobImage(file, name:;
pipeline.process(image).then((BaseImage result) {
  // result is a BlobImage, and will always be with the default settings,
  // but I may change the API so we can receive a CanvasImage.
  Blob blob = (result as BlobImage).blob;

  // start a "download", so the image is saved

  String url;
  try {
    url = Url.createObjectUrl(blob);
    AnchorElement a = new AnchorElement(); = "${}.resized.jpg";
    a.href = url;;
  } finally {
    if (url != null) Url.revokeObjectUrl(url);

Getting Started #

Check out the project for an example and details on how to deal with the pipeline and BaseImage objects.

0.11.0 #

  • the library is updated to support and require Dart 2.2

0.10.0 #

  • bumped exifdart version
  • the library now requires Dart 2

0.9.4 #

  • bumped exifdart version

0.9.3+1 #

  • Added polyfill to fix IE11's lack of support of quality parameters in HTMLCanvasElement.toBlob

0.9.3 #

  • The pipeline can skip encoding the image to file and return with a CanvasImage (or a BlobImage if no adjustment was needed at all)

0.9.2 #

  • Added wrappers for Url.createObjectUrl and Url.revokeObjectUrl in BlobImage
  • Made a function private that was previously public by accident

0.9.1+2 #

  • Fixed handling of files without EXIF

0.9.1+1 #

Maintenance release.

0.9.1 #

  • Added the option to use the not really recommended native scaler: it applies no filters, the photos will look ugly. But it's fast.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  image_whisperer: ^0.11.0

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:image_whisperer/image_whisperer.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Jan 14, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.0
  • pana: 0.13.4

Health suggestions

Fix lib/src/classes.dart. (-12.66 points)

Analysis of lib/src/classes.dart reported 27 hints, including:

line 29 col 37: Unnecessary new keyword.

line 30 col 24: Unnecessary new keyword.

line 32 col 28: Unnecessary new keyword.

line 41 col 26: Unnecessary new keyword.

line 55 col 58: Unnecessary new keyword.

Maintenance suggestions

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package.

Common filename patterns include main.dart, example.dart, and image_whisperer.dart. Packages with multiple examples should provide example/

For more information see the pub package layout conventions.

The package description is too short. (-6 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.2.0 <3.0.0
exifdart >=0.7.0 <0.8.0 0.7.0+3