Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .github/workflows/runnable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,30 @@ jobs:
melos bootstrap
melos run get
- run: melos run try_build_apk

test_web:
needs: analyze
name: Test build web on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest ]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
distribution: 'adopt'
java-version: '11.x'
- uses: subosito/flutter-action@v2
with:
channel: 'stable'
- run: dart --version
- run: flutter --version
- run: flutter pub get
- name: Get melos
run: dart pub global activate melos
- name: Init melos
run: |
melos bootstrap
melos run get
- run: melos run try_build_web
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,4 @@
example/macos/Flutter/ephemeral/flutter_export_environment.sh

pubspec_overrides.yaml
pubspec.lock
27 changes: 27 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,30 @@ melos bootstrap
```

[melos]: https://melos.invertase.dev

## About document

### About README

All packages use the same README file.

All changes need to be put into the README in the root directory and the `melos run cp_files` command needs to be run to synchronize the documentation.

### About CHANGELOG

The CHANGELOG for each package is independent.
When you submit a pull request, please also modify the CHANGELOG file with the changes.

If you don't have the current version of the section, you can add a secondary title

```md
## Unreleased

Feature:
- xxxx

Or

Fix:
- xxx
```
53 changes: 51 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
[![GitHub license](https://img.shields.io/github/license/fluttercandies/flutter_image_compress?style=flat-square)](https://github.com/fluttercandies/flutter_image_compress/blob/main/LICENSE)
[![GitHub stars](https://img.shields.io/github/stars/fluttercandies/flutter_image_compress.svg?style=social&label=Stars)](https://github.com/fluttercandies/flutter_image_compress)
[![Awesome Flutter](https://img.shields.io/badge/Awesome-Flutter-blue.svg?longCache=true&style=flat-square)](https://stackoverflow.com/questions/tagged/flutter?sort=votes)
<a target="_blank" href="https://jq.qq.com/?_wv=1027&k=5bcc0gy"><img border="0" src="https://pub.idqqimg.com/wpa/images/group.png" alt="FlutterCandies" title="FlutterCandies"></a>
[![FlutterCandies](https://pub.idqqimg.com/wpa/images/group.png)](https://jq.qq.com/?_wv=1027&k=5bcc0gy)

Compresses image as native plugin (Obj-C/Kotlin). This library works on Android and iOS.

- [flutter_image_compress](#flutter_image_compress)
- [flutter\_image\_compress](#flutter_image_compress)
- [Why don't you use dart to do it](#why-dont-you-use-dart-to-do-it)
- [Usage](#usage)
- [About common params](#about-common-params)
Expand All @@ -31,6 +31,8 @@ Compresses image as native plugin (Obj-C/Kotlin). This library works on Android
- [Troubleshooting](#troubleshooting)
- [Compressing returns `null`](#compressing-returns-null)
- [About EXIF information](#about-exif-information)
- [Web](#web)
- [Platform Features](#platform-features)

## Why don't you use dart to do it

Expand Down Expand Up @@ -320,3 +322,50 @@ but not `direction` information.
- System API on Android.
- HEIF encoder: System API.
- [HeifWriter](https://developer.android.com/jetpack/androidx/releases/heifwriter) on Android P+.

## Web

The web implementation is not required for many people,
so you need to manually add the web plugin to pubspec.yaml.

```yaml
dependencies:
flutter_image_compress_web: ^0.1.0
```

[![pub package](https://img.shields.io/pub/v/flutter_image_compress_web.svg)](https://pub.dartlang.org/packages/flutter_image_compress_web)

This plugin uses [pica][] to implement compression.

Currently, [debug mode does not allow you to use the dynamic script loading scheme][flutter-126131].
And when you actually deploy, you may choose server deployment or cdn deployment, so here we suggest you add script node to head or body by yourself.

[flutter-126131]: https://github.com/flutter/flutter/issues/126131

```html
<script src="https://cdn.jsdelivr.net/npm/pica@9.0.1/dist/pica.min.js" ></script>

or your other cdn link
```

About web compatibility: two methods with file will throw an exception when used on the web.

[pica]: https://www.npmjs.com/package/pica?activeTab=readme

## Platform Features

| Feature | Android | iOS | Web |
| :------------------------- | :-----: | :---: | :---------------------: |
| method: compressWithList | ✅ | ✅ | ✅ |
| method: compressAssetImage | ✅ | ✅ | ✅ |
| method: compressWithFile | ✅ | ✅ | ❌ |
| method: compressAndGetFile | ✅ | ✅ | ❌ |
| format: jpeg | ✅ | ✅ | ✅ |
| format: png | ✅ | ✅ | ✅ |
| format: webp | ✅ | ✅ | [🌐][webp-compatibility] |
| format: heic | ✅ | ✅ | ❌ |
| param: quality | ✅ | ✅ | [🌐][webp-compatibility] |
| param: rotate | ✅ | ✅ | ❌ |
| param: keepExif | ✅ | ✅ | ❌ |

[webp-compatibility]: https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob#browser_compatibility "Browser support"
12 changes: 11 additions & 1 deletion melos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,25 @@ scripts:
format:
exec: dart format --set-exit-if-changed .
try_build_apk:
exec: flutter build apk --debug
exec: |
flutter pub get

flutter build apk --debug
packageFilters:
fileExists: lib/main.dart
try_build_ios:
exec: |
flutter pub get

flutter build ios --debug --no-codesign
packageFilters:
fileExists: lib/main.dart
try_build_web:
exec: |
flutter pub get
flutter build web
packageFilters:
fileExists: lib/main.dart
cp_files:
exec: |
if [ -f "../../LICENSE" ]; then
Expand Down
53 changes: 51 additions & 2 deletions packages/flutter_image_compress/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
[![GitHub license](https://img.shields.io/github/license/fluttercandies/flutter_image_compress?style=flat-square)](https://github.com/fluttercandies/flutter_image_compress/blob/main/LICENSE)
[![GitHub stars](https://img.shields.io/github/stars/fluttercandies/flutter_image_compress.svg?style=social&label=Stars)](https://github.com/fluttercandies/flutter_image_compress)
[![Awesome Flutter](https://img.shields.io/badge/Awesome-Flutter-blue.svg?longCache=true&style=flat-square)](https://stackoverflow.com/questions/tagged/flutter?sort=votes)
<a target="_blank" href="https://jq.qq.com/?_wv=1027&k=5bcc0gy"><img border="0" src="https://pub.idqqimg.com/wpa/images/group.png" alt="FlutterCandies" title="FlutterCandies"></a>
[![FlutterCandies](https://pub.idqqimg.com/wpa/images/group.png)](https://jq.qq.com/?_wv=1027&k=5bcc0gy)

Compresses image as native plugin (Obj-C/Kotlin). This library works on Android and iOS.

- [flutter_image_compress](#flutter_image_compress)
- [flutter\_image\_compress](#flutter_image_compress)
- [Why don't you use dart to do it](#why-dont-you-use-dart-to-do-it)
- [Usage](#usage)
- [About common params](#about-common-params)
Expand All @@ -31,6 +31,8 @@ Compresses image as native plugin (Obj-C/Kotlin). This library works on Android
- [Troubleshooting](#troubleshooting)
- [Compressing returns `null`](#compressing-returns-null)
- [About EXIF information](#about-exif-information)
- [Web](#web)
- [Platform Features](#platform-features)

## Why don't you use dart to do it

Expand Down Expand Up @@ -320,3 +322,50 @@ but not `direction` information.
- System API on Android.
- HEIF encoder: System API.
- [HeifWriter](https://developer.android.com/jetpack/androidx/releases/heifwriter) on Android P+.

## Web

The web implementation is not required for many people,
so you need to manually add the web plugin to pubspec.yaml.

```yaml
dependencies:
flutter_image_compress_web: ^0.1.0
```

[![pub package](https://img.shields.io/pub/v/flutter_image_compress_web.svg)](https://pub.dartlang.org/packages/flutter_image_compress_web)

This plugin uses [pica][] to implement compression.

Currently, [debug mode does not allow you to use the dynamic script loading scheme][flutter-126131].
And when you actually deploy, you may choose server deployment or cdn deployment, so here we suggest you add script node to head or body by yourself.

[flutter-126131]: https://github.com/flutter/flutter/issues/126131

```html
<script src="https://cdn.jsdelivr.net/npm/pica@9.0.1/dist/pica.min.js" ></script>

or your other cdn link
```

About web compatibility: two methods with file will throw an exception when used on the web.

[pica]: https://www.npmjs.com/package/pica?activeTab=readme

## Platform Features

| Feature | Android | iOS | Web |
| :------------------------- | :-----: | :---: | :---------------------: |
| method: compressWithList | ✅ | ✅ | ✅ |
| method: compressAssetImage | ✅ | ✅ | ✅ |
| method: compressWithFile | ✅ | ✅ | ❌ |
| method: compressAndGetFile | ✅ | ✅ | ❌ |
| format: jpeg | ✅ | ✅ | ✅ |
| format: png | ✅ | ✅ | ✅ |
| format: webp | ✅ | ✅ | [🌐][webp-compatibility] |
| format: heic | ✅ | ✅ | ❌ |
| param: quality | ✅ | ✅ | [🌐][webp-compatibility] |
| param: rotate | ✅ | ✅ | ❌ |
| param: keepExif | ✅ | ✅ | ❌ |

[webp-compatibility]: https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob#browser_compatibility "Browser support"
28 changes: 25 additions & 3 deletions packages/flutter_image_compress/example/.metadata
Original file line number Diff line number Diff line change
@@ -1,8 +1,30 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled and should not be manually edited.
# This file should be version controlled.

version:
revision: 3b309bda072a6b326e8aa4591a5836af600923ce
channel: dev
revision: b06b8b2710955028a6b562f5aa6fe62941d6febf
channel: stable

project_type: app

# Tracks metadata for the flutter migrate command
migration:
platforms:
- platform: root
create_revision: b06b8b2710955028a6b562f5aa6fe62941d6febf
base_revision: b06b8b2710955028a6b562f5aa6fe62941d6febf
- platform: web
create_revision: b06b8b2710955028a6b562f5aa6fe62941d6febf
base_revision: b06b8b2710955028a6b562f5aa6fe62941d6febf

# User provided section

# List of Local paths (relative to this file) that should be
# ignored by the migrate tool.
#
# Files that are not part of the templates will be ignored by default.
unmanaged_files:
- 'lib/main.dart'
- 'ios/Runner.xcodeproj/project.pbxproj'
22 changes: 22 additions & 0 deletions packages/flutter_image_compress/example/lib/button.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import 'package:flutter/material.dart';

class TextButton extends StatelessWidget {
const TextButton({
Key? key,
required this.onPressed,
required this.child,
}) : super(key: key);
final VoidCallback onPressed;
final Widget child;

@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.all(8.0),
child: ElevatedButton(
onPressed: onPressed,
child: child,
),
);
}
}
Loading