image 2.1.4

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 99

image #

Build Status

Overview #

A Dart library providing the ability to load, save and manipulate images in a variety of different file formats.

The library has no reliance on dart:io, so it can be used for both server and web applications.

Supported Image Formats:

Read/Write:

  • PNG / Animated APNG
  • JPEG
  • Targa
  • GIF / Animated GIF
  • PVR(PVRTC)

Read Only:

  • WebP / Animated WebP
  • TIFF
  • Photoshop PSD
  • OpenEXR

Documentation #

API #

Examples #

Format Decoding Functions #

Samples #

Load an image, resize it, and save it as a png:

import 'dart:io';
import 'package:image/image.dart';
void main() {
  // Read an image from file (webp in this case).
  // decodeImage will identify the format of the image and use the appropriate
  // decoder.
  Image image = decodeImage(File('test.webp').readAsBytesSync());

  // Resize the image to a 120x? thumbnail (maintaining the aspect ratio).
  Image thumbnail = copyResize(image, width: 120);

  // Save the thumbnail as a PNG.
  File('thumbnail.png')..writeAsBytesSync(encodePng(thumbnail));
}

2.1.4 - June 01, 2019 #

  • Optimize fillRect, drawPixel, and other drawing functions when opaque colors are used.

2.1.3 - May 26, 2019 #

  • Revert the internal color format to #AABBGGRR.

2.1.2 - May 25, 2019 #

  • Fix crash decoding some Jpeg images.
  • Fix infinite recursion crash with fillFlood when fill color is the same as the start pixel color.

2.1.1 - May 22, 2019 #

  • Fix typo and missing license in license file.

2.1.0 - May 15, 2019 #

  • Big API clean-up to bring it up to a more modern Dart syntax.

2.0.9 - May 10, 2019 #

  • Use strict dartanalysys settings and clean up code.

2.0.8 - May 8, 2019 #

  • Add ability to quantize an image to any number of colors.
  • Optimizations for the JPEG decoder.
  • Use #AARRGGBB for colors instead of #AABBGGRR, to be compatible with Flutter image class.
  • Add floodfill drawing function.
  • CopyRectify to transform an arbitrary quad to the full image.
  • Improve performance of CopyResize.

2.0.7 - February 5, 2019 #

  • Improve JPEG decoding performance.
  • Decode and encode ICC profile data from PNG images.

2.0.6 - January 26, 2019 #

  • bakeOrientation will clear the image's exif orientation properties.
  • copyResize will correctly maintain the image's orientation.

2.0.5 - December 1, 2018 #

  • Added APNG (animated PNG) encoding.
  • Optimized drawString function.

2.0.3 - June 6, 2018 #

  • copyResize can maintain aspect ratio when resizing height by using -1 for the width.
  • Added example for loading and processing images in an isolate.

2.0.2 - June 1, 2018 #

  • Re-added decoding of orientation exif value from jpeg images.
  • Added bake_orientation function, which will rotate an image so that it physically matches its orientation exif value, useful for rotating an image prior to exporting it to a format that does not support exif data.

2.0.1 - May 28, 2018 #

Fix for bad jpeg files when encoding EXIF data.

2.0.0 - May 22, 2018 #

Remove the use of Dart 1 upper-case constants. Update SDK dependency to a 2.0 development release.

1.1.33 - May 16, 2018 #

Maintain EXIF data from JPEG images.

1.1.32 - May 9, 2018 #

Remove the use of part and part of in the main library.

1.1.30 - March 10, 2018 #

Update pubspec to account for the new version of xml package that has been published.

1.1.29 - September 18, 2017 #

  • Add fixes for strong mode support.

1.1.28 - May 27, 2017 #

  • Update pubspec to fix recent pub issues.
  • Rename changelog.txt to CHANGELOG.md.
  • Fix for 8-bit PNG decoding.

1.1.27 - May 14, 2017 #

  • Fix crash decoding some jpeg images.

1.1.24 - January 23, 2015 #

  • PVR encoding/decoding
  • Fix 16-bit tiff decoding

1.1.23 - September 15, 2014 #

  • Fix alpha for PSD images.

1.1.22 - July 31, 2014 #

  • Various bug fixes

1.1.21 - June 19, 2014 #

  • Add drawImage function
  • Update XML dependency to 2.0.0

1.1.20 - April 26, 2014 #

  • Fix OpenEXR decoder for dart2js

1.1.19 - April 15, 2014 #

  • OpenEXR fixes.

1.1.18 - April 06, 2014 #

  • Added OpenEXR format docoder.

1.1.17 - April 02, 2014 #

  • Add Photoshop PSD format decoder

1.1.16 - March 24, 2014 #

  • Fix JPEG encoder for compression quality < 100.

1.1.15 - March 10, 2014 #

  • Update to new version of archive.

1.1.14 - February 26, 2014 #

  • Optimizations

1.1.13 - February 16, 2014 #

  • Added TIFF decoder

1.1.10 - February 11, 2014 #

  • Added APNG animated PNG decoding support.
  • Improved JPEG decoding performance
  • Various bug fixes

1.1.8 - February 01, 2014 #

  • Added GIF decoding support, including animated gifs.

1.1.7 - January 28, 2014 #

  • Added WebP decoding support, included animated WebP.

example/example.dart

import 'dart:io';
import 'package:image/image.dart';
void main() {
  // Read an image from file (webp in this case).
  // decodeImage will identify the format of the image and use the appropriate
  // decoder.
  Image image = decodeImage(new File('test.webp').readAsBytesSync());

  // Resize the image to a 120x? thumbnail (maintaining the aspect ratio).
  Image thumbnail = copyResize(image, width: 120);

  // Save the thumbnail as a PNG.
  new File('thumbnail.png').writeAsBytesSync(encodePng(thumbnail));
}

Use this package as a library

1. Depend on it

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


dependencies:
  image: ^2.1.4

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/image.dart';
  
Version Uploaded Documentation Archive
2.1.4 Jun 2, 2019 Go to the documentation of image 2.1.4 Download image 2.1.4 archive
2.1.3 May 27, 2019 Go to the documentation of image 2.1.3 Download image 2.1.3 archive
2.1.2 May 26, 2019 Go to the documentation of image 2.1.2 Download image 2.1.2 archive
2.1.1 May 22, 2019 Go to the documentation of image 2.1.1 Download image 2.1.1 archive
2.1.0 May 16, 2019 Go to the documentation of image 2.1.0 Download image 2.1.0 archive
2.0.9 May 11, 2019 Go to the documentation of image 2.0.9 Download image 2.0.9 archive
2.0.8 May 9, 2019 Go to the documentation of image 2.0.8 Download image 2.0.8 archive
2.0.7 Feb 5, 2019 Go to the documentation of image 2.0.7 Download image 2.0.7 archive
2.0.6 Jan 27, 2019 Go to the documentation of image 2.0.6 Download image 2.0.6 archive
2.0.5 Dec 2, 2018 Go to the documentation of image 2.0.5 Download image 2.0.5 archive

All 48 versions...

Popularity:
Describes how popular the package is relative to other packages. [more]
99
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
99
Learn more about scoring.

We analyzed this package on Jun 25, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.3.2
  • pana: 0.12.18

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:image/image.dart.

Health suggestions

Format lib/src/animation.dart.

Run dartfmt to format lib/src/animation.dart.

Format lib/src/bitmap_font.dart.

Run dartfmt to format lib/src/bitmap_font.dart.

Format lib/src/color.dart.

Run dartfmt to format lib/src/color.dart.

Fix additional 35 files with analysis or formatting issues.

Additional issues in the following files:

  • lib/src/draw/draw_image.dart (Run dartfmt to format lib/src/draw/draw_image.dart.)
  • lib/src/draw/draw_line.dart (Run dartfmt to format lib/src/draw/draw_line.dart.)
  • lib/src/draw/fill_flood.dart (Run dartfmt to format lib/src/draw/fill_flood.dart.)
  • lib/src/effects/drop_shadow.dart (Run dartfmt to format lib/src/effects/drop_shadow.dart.)
  • lib/src/filter/adjust_color.dart (Run dartfmt to format lib/src/filter/adjust_color.dart.)
  • lib/src/filter/color_offset.dart (Run dartfmt to format lib/src/filter/color_offset.dart.)
  • lib/src/filter/convolution.dart (Run dartfmt to format lib/src/filter/convolution.dart.)
  • lib/src/filter/emboss.dart (Run dartfmt to format lib/src/filter/emboss.dart.)
  • lib/src/filter/noise.dart (Run dartfmt to format lib/src/filter/noise.dart.)
  • lib/src/filter/pixelate.dart (Run dartfmt to format lib/src/filter/pixelate.dart.)
  • lib/src/filter/quantize.dart (Run dartfmt to format lib/src/filter/quantize.dart.)
  • lib/src/filter/remap_colors.dart (Run dartfmt to format lib/src/filter/remap_colors.dart.)
  • lib/src/filter/separable_kernel.dart (Run dartfmt to format lib/src/filter/separable_kernel.dart.)
  • lib/src/filter/smooth.dart (Run dartfmt to format lib/src/filter/smooth.dart.)
  • lib/src/filter/vignette.dart (Run dartfmt to format lib/src/filter/vignette.dart.)
  • lib/src/formats/jpeg_encoder.dart (Run dartfmt to format lib/src/formats/jpeg_encoder.dart.)
  • lib/src/formats/png_encoder.dart (Run dartfmt to format lib/src/formats/png_encoder.dart.)
  • lib/src/formats/pvrtc/pvrtc_color.dart (Run dartfmt to format lib/src/formats/pvrtc/pvrtc_color.dart.)
  • lib/src/formats/pvrtc/pvrtc_color_bounding_box.dart (Run dartfmt to format lib/src/formats/pvrtc/pvrtc_color_bounding_box.dart.)
  • lib/src/formats/pvrtc/pvrtc_encoder.dart (Run dartfmt to format lib/src/formats/pvrtc/pvrtc_encoder.dart.)
  • lib/src/formats/webp/vp8_filter.dart (Run dartfmt to format lib/src/formats/webp/vp8_filter.dart.)
  • lib/src/formats/webp/vp8l.dart (Run dartfmt to format lib/src/formats/webp/vp8l.dart.)
  • lib/src/image.dart (Run dartfmt to format lib/src/image.dart.)
  • lib/src/internal/clamp.dart (Run dartfmt to format lib/src/internal/clamp.dart.)
  • lib/src/transform/copy_crop.dart (Run dartfmt to format lib/src/transform/copy_crop.dart.)
  • lib/src/transform/copy_into.dart (Run dartfmt to format lib/src/transform/copy_into.dart.)
  • lib/src/transform/copy_rectify.dart (Run dartfmt to format lib/src/transform/copy_rectify.dart.)
  • lib/src/transform/copy_resize.dart (Run dartfmt to format lib/src/transform/copy_resize.dart.)
  • lib/src/transform/copy_resize_crop_square.dart (Run dartfmt to format lib/src/transform/copy_resize_crop_square.dart.)
  • lib/src/transform/copy_rotate.dart (Run dartfmt to format lib/src/transform/copy_rotate.dart.)
  • lib/src/transform/flip.dart (Run dartfmt to format lib/src/transform/flip.dart.)
  • lib/src/transform/trim.dart (Run dartfmt to format lib/src/transform/trim.dart.)
  • lib/src/util/input_buffer.dart (Run dartfmt to format lib/src/util/input_buffer.dart.)
  • lib/src/util/interpolation.dart (Run dartfmt to format lib/src/util/interpolation.dart.)
  • lib/src/util/point.dart (Run dartfmt to format lib/src/util/point.dart.)

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.49.0 <3.0.0
archive >=1.0.16 <3.0.0 2.0.10
xml >=3.2.5 <4.0.0 3.5.0
Transitive dependencies
args 1.5.2
charcode 1.1.2
collection 1.14.11
convert 2.1.1
crypto 2.0.6
path 1.6.2
petitparser 2.3.0
typed_data 1.1.6
Dev dependencies
build_runner >=1.3.0 <2.0.0
build_web_compilers >=0.3.6 <2.0.0
pedantic ^1.0.0
test >=0.12.42 <2.0.0