image 2.0.4

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

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' as 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 Io.File('test.webp').readAsBytesSync());

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

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

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 doesn't 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, 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.0.4"

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

Alternatively, your editor might support pub get or flutter packages 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.0.4 Jun 14, 2018 Go to the documentation of image 2.0.4 Download image 2.0.4 archive
2.0.3 Jun 7, 2018 Go to the documentation of image 2.0.3 Download image 2.0.3 archive
2.0.2 Jun 2, 2018 Go to the documentation of image 2.0.2 Download image 2.0.2 archive
2.0.1 May 29, 2018 Go to the documentation of image 2.0.1 Download image 2.0.1 archive
2.0.0 May 27, 2018 Go to the documentation of image 2.0.0 Download image 2.0.0 archive
1.1.33 May 17, 2018 Go to the documentation of image 1.1.33 Download image 1.1.33 archive
1.1.32 May 10, 2018 Go to the documentation of image 1.1.32 Download image 1.1.32 archive
1.1.31 Apr 20, 2018 Go to the documentation of image 1.1.31 Download image 1.1.31 archive
1.1.30 Mar 11, 2018 Go to the documentation of image 1.1.30 Download image 1.1.30 archive
1.1.29 Sep 19, 2017 Go to the documentation of image 1.1.29 Download image 1.1.29 archive

All 38 versions...

Analysis

We analyzed this package on Jul 13, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0-dev.63.0
  • pana: 0.11.3

Scores

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

Platforms

Detected platforms: Flutter, web, other

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

Suggestions

  • Fix analysis and formatting issues.

    Analysis or formatting checks reported 169 hints.

    Run dartfmt to format lib/image.dart.

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

    Similar analysis of the following files failed:

    • lib/src/bitmap_font.dart (hint)
    • lib/src/color.dart (hint)
    • lib/src/draw/draw_char.dart (hint)
    • lib/src/draw/draw_circle.dart (hint)
    • lib/src/draw/draw_image.dart (hint)
    • lib/src/draw/draw_line.dart (hint)
    • lib/src/draw/draw_string.dart (hint)
    • lib/src/effects/drop_shadow.dart (hint)
    • lib/src/exif_data.dart (hint)
    • lib/src/filter/adjust_color.dart (hint)
    • lib/src/filter/bump_to_normal.dart (hint)
    • lib/src/filter/convolution.dart (hint)
    • lib/src/filter/emboss.dart (hint)
    • lib/src/filter/noise.dart (hint)
    • lib/src/filter/pixelate.dart (hint)
    • lib/src/filter/remap_colors.dart (hint)
    • lib/src/filter/seperable_kernel.dart (hint)
    • lib/src/filter/smooth.dart (hint)
    • lib/src/filter/sobel.dart (hint)
    • lib/src/filter/vignette.dart (hint)
    • lib/src/fonts/arial_14.dart (hint)
    • lib/src/fonts/arial_24.dart (hint)
    • lib/src/fonts/arial_48.dart (hint)
    • lib/src/formats/decode_info.dart (hint)
    • lib/src/formats/exr/exr_b44_compressor.dart (hint)
    • lib/src/formats/exr/exr_channel.dart (hint)
    • lib/src/formats/exr/exr_compressor.dart (hint)
    • lib/src/formats/exr/exr_huffman.dart (hint)
    • lib/src/formats/exr/exr_image.dart (hint)
    • lib/src/formats/exr/exr_part.dart (hint)
    • lib/src/formats/exr/exr_piz_compressor.dart (hint)
    • lib/src/formats/exr/exr_pxr24_compressor.dart (hint)
    • lib/src/formats/exr/exr_rle_compressor.dart (hint)
    • lib/src/formats/exr/exr_wavelet.dart (hint)
    • lib/src/formats/exr/exr_zip_compressor.dart (hint)
    • lib/src/formats/exr_decoder.dart (hint)
    • lib/src/formats/formats.dart (hint)
    • lib/src/formats/gif/gif_color_map.dart (hint)
    • lib/src/formats/gif/gif_image_desc.dart (hint)
    • lib/src/formats/gif_decoder.dart (hint)
    • lib/src/formats/gif_encoder.dart (hint)
    • lib/src/formats/jpeg/jpeg.dart (hint)
    • lib/src/formats/jpeg/jpeg_component.dart (hint)
    • lib/src/formats/jpeg/jpeg_data.dart (hint)
    • lib/src/formats/jpeg/jpeg_frame.dart (hint)
    • lib/src/formats/jpeg/jpeg_scan.dart (hint)
    • lib/src/formats/jpeg_encoder.dart (hint)
    • lib/src/formats/png_decoder.dart (hint)
    • lib/src/formats/png_encoder.dart (hint)
    • lib/src/formats/psd/layer_data/psd_layer_additional_data.dart (hint)
    • lib/src/formats/psd/layer_data/psd_layer_section_divider.dart (hint)
    • lib/src/formats/psd/psd_blending_ranges.dart (hint)
    • lib/src/formats/psd/psd_channel.dart (hint)
    • lib/src/formats/psd/psd_image.dart (hint)
    • lib/src/formats/psd/psd_layer.dart (hint)
    • lib/src/formats/pvrtc/pvrtc_bit_utility.dart (hint)
    • lib/src/formats/pvrtc/pvrtc_color.dart (hint)
    • lib/src/formats/pvrtc/pvrtc_color_bounding_box.dart (hint)
    • lib/src/formats/pvrtc/pvrtc_decoder.dart (hint)
    • lib/src/formats/pvrtc/pvrtc_encoder.dart (hint)
    • lib/src/formats/pvrtc/pvrtc_packet.dart (hint)
    • lib/src/formats/tga_decoder.dart (hint)
    • lib/src/formats/tiff/tiff_bit_reader.dart (hint)
    • lib/src/formats/tiff/tiff_entry.dart (hint)
    • lib/src/formats/tiff/tiff_fax_decoder.dart (hint)
    • lib/src/formats/tiff/tiff_image.dart (hint)
    • lib/src/formats/tiff/tiff_lzw_decoder.dart (hint)
    • lib/src/formats/tiff_decoder.dart (hint)
    • lib/src/formats/webp/vp8.dart (hint)
    • lib/src/formats/webp/vp8_bit_reader.dart (hint)
    • lib/src/formats/webp/vp8_filter.dart (hint)
    • lib/src/formats/webp/vp8_types.dart (hint)
    • lib/src/formats/webp/vp8l.dart (hint)
    • lib/src/formats/webp/vp8l_bit_reader.dart (hint)
    • lib/src/formats/webp/vp8l_color_cache.dart (hint)
    • lib/src/formats/webp/vp8l_transform.dart (hint)
    • lib/src/formats/webp/webp_alpha.dart (hint)
    • lib/src/formats/webp/webp_filters.dart (hint)
    • lib/src/formats/webp/webp_frame.dart (hint)
    • lib/src/formats/webp/webp_huffman.dart (hint)
    • lib/src/formats/webp/webp_info.dart (hint)
    • lib/src/formats/webp_decoder.dart (hint)
    • lib/src/formats/webp_encoder.dart (hint)
    • lib/src/hdr/half.dart (hint)
    • lib/src/hdr/hdr_bloom.dart (hint)
    • lib/src/hdr/hdr_image.dart (hint)
    • lib/src/hdr/hdr_slice.dart (hint)
    • lib/src/hdr/hdr_to_image.dart (hint)
    • lib/src/hdr/reinhard_tone_map.dart (hint)
    • lib/src/image.dart (hint)
    • lib/src/internal/bit_operators.dart (hint)
    • lib/src/transform/copy_into.dart (hint)
    • lib/src/transform/copy_resize.dart (hint)
    • lib/src/transform/copy_rotate.dart (hint)
    • lib/src/transform/trim.dart (hint)
    • lib/src/util/clip_line.dart (hint)
    • lib/src/util/input_buffer.dart (hint)
    • lib/src/util/interpolation.dart (hint)
    • lib/src/util/min_max.dart (hint)
    • lib/src/util/neural_quantizer.dart (hint)
    • lib/src/util/output_buffer.dart (hint)
    • lib/src/util/random.dart (hint)

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.0
xml >=2.0.0 <4.0.0 3.0.0
Transitive dependencies
args 1.4.3
charcode 1.1.2
collection 1.14.10
convert 2.0.1
crypto 2.0.5
matcher 0.12.3
path 1.6.1
petitparser 1.7.6
stack_trace 1.9.2
typed_data 1.1.5
Dev dependencies
build_runner ^0.8.8
build_test ^0.10.2
build_web_compilers ^0.4.0
test >=0.12.30 <1.0.0