Skip to content

Commit

Permalink
feat: created a function to compress image
Browse files Browse the repository at this point in the history
  • Loading branch information
Andre Rossi committed Dec 11, 2023
1 parent 31cc113 commit 332e405
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
18 changes: 18 additions & 0 deletions lib/src/services/ds_media_format.service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,28 @@ import 'dart:io';

import 'package:ffmpeg_kit_flutter_full_gpl/ffmpeg_kit.dart';
import 'package:ffmpeg_kit_flutter_full_gpl/return_code.dart';
import 'package:flutter_image_compress/flutter_image_compress.dart';
import 'package:path/path.dart' as path_utils;
import 'package:video_compress/video_compress.dart';

abstract class DSMediaFormatService {
static Future<bool> formatImage({
required final String input,
required final String output,
}) async {
try {
final result = await FlutterImageCompress.compressAndGetFile(
input,
output,
quality: 80,
);

return File(result!.path).exists();
} catch (e) {
return false;
}
}

static Future<bool> formatVideo({
required final String input,
required final String output,
Expand Down
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ dependencies:
mime: ^1.0.4
crypto: ^3.0.3
video_compress: ^3.1.2
flutter_image_compress: ^2.1.0

dev_dependencies:
flutter_test:
Expand Down

0 comments on commit 332e405

Please sign in to comment.