Skip to content

Commit

Permalink
Merge pull request #20 from OpenFlutter/0.2.2
Browse files Browse the repository at this point in the history
add dart doc
  • Loading branch information
CaiJingLong authored Nov 28, 2018
2 parents 07d85c8 + c61209d commit dbe0c71
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

## 0.2.2

add some dart doc

## 0.2.1

update readme
Expand Down
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ No problems found at present.

```yaml
dependencies:
flutter_image_compress: ^0.2.1
flutter_image_compress: ^0.2.2
```
```dart
Expand Down Expand Up @@ -123,8 +123,6 @@ write to file
}
```



## android build error

```
Expand All @@ -142,5 +140,6 @@ you need edit your kotlin version to 1.2.71+

If flutter supports more platforms (windows, mac, linux, other) in the future and you use this library, propose issue / PR

## ABOUT EXIF
## ABOUT EXIF

Using this library, EXIF information will be removed.
26 changes: 26 additions & 0 deletions lib/flutter_image_compress.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,30 @@ import 'package:flutter/material.dart';

import 'package:flutter/services.dart';

/// Image Compress
///
/// static method will help you compress image
///
/// most method will return [List<int>]
///
/// convert List<int> to [Uint8List] and use [Image.memory(uint8List)] to display image
/// ```dart
/// var u8 = Uint8List.fromList(list)
/// ImageProvider provider = MemoryImage(Uint8List.fromList(list));
/// ```
///
/// The returned image will retain the proportion of the original image.
///
/// Compress image will remove EXIF.
///
/// image result is jpeg format.
///
/// support rotate
///
class FlutterImageCompress {
static const MethodChannel _channel = const MethodChannel('flutter_image_compress');

/// compress image from [List<int>] to [List<int>]
static Future<List<int>> compressWithList(
List<int> image, {
int minWidth = 1920,
Expand All @@ -26,6 +47,7 @@ class FlutterImageCompress {
return convertDynamic(result);
}

/// compress file of [path] to [List<int>]
static Future<List<int>> compressWithFile(
String path, {
int minWidth = 1920,
Expand All @@ -43,6 +65,7 @@ class FlutterImageCompress {
return convertDynamic(result);
}

/// from [path] to [targetPath]
static Future<File> compressAndGetFile(
String path,
String targetPath, {
Expand All @@ -67,6 +90,7 @@ class FlutterImageCompress {
return File(result);
}

/// from [asset] to [List<int>]
static Future<List<int>> compressAssetImage(
String assetName, {
int minWidth = 1920,
Expand Down Expand Up @@ -121,11 +145,13 @@ class FlutterImageCompress {
// );
// }

/// convert [List<dynamic>] to [List<int>]
static List<int> convertDynamic(List<dynamic> list) {
return list.where((item) => item is int).map((item) => item as int).toList();
}
}

/// get [ImageInfo] from [ImageProvider]
Future<ImageInfo> getImageInfo(BuildContext context, ImageProvider provider, {Size size}) async {
final ImageConfiguration config = createLocalImageConfiguration(context, size: size);
final Completer<ImageInfo> completer = new Completer<ImageInfo>();
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: flutter_image_compress
description: compress image with native code(objc kotlin), it's faster. This library can work on android/ios.
version: 0.2.1
version: 0.2.2
author: caijinglong<cjl_spy@163.com>
homepage: https://github.com/OpenFlutter/flutter_image_compress

Expand Down

0 comments on commit dbe0c71

Please sign in to comment.