Compare commits
1 Commits
send_ott
...
decoded_im
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
24b88a186c |
@@ -7,6 +7,7 @@ import "dart:ui";
|
|||||||
import "package:exif_reader/exif_reader.dart";
|
import "package:exif_reader/exif_reader.dart";
|
||||||
import 'package:flutter/painting.dart' as paint show decodeImageFromList;
|
import 'package:flutter/painting.dart' as paint show decodeImageFromList;
|
||||||
import "package:flutter_image_compress/flutter_image_compress.dart";
|
import "package:flutter_image_compress/flutter_image_compress.dart";
|
||||||
|
import 'package:image/image.dart' as img_pkg;
|
||||||
import "package:logging/logging.dart";
|
import "package:logging/logging.dart";
|
||||||
import 'package:ml_linalg/linalg.dart';
|
import 'package:ml_linalg/linalg.dart';
|
||||||
import "package:photos/models/ml/face/box.dart";
|
import "package:photos/models/ml/face/box.dart";
|
||||||
@@ -53,7 +54,45 @@ Future<DecodedImage> decodeImageFromPath(
|
|||||||
String imagePath, {
|
String imagePath, {
|
||||||
required bool includeRgbaBytes,
|
required bool includeRgbaBytes,
|
||||||
required bool includeDartUiImage,
|
required bool includeDartUiImage,
|
||||||
|
bool inBackground = false,
|
||||||
}) async {
|
}) async {
|
||||||
|
if (inBackground) {
|
||||||
|
if (includeDartUiImage) {
|
||||||
|
_logger.severe(
|
||||||
|
"Decoding image in background with Dart UI Image is not possible!",
|
||||||
|
);
|
||||||
|
throw Exception(
|
||||||
|
"Decoding image in background with Dart UI Image is not possible!",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (!includeRgbaBytes) {
|
||||||
|
_logger.severe(
|
||||||
|
"Decoding image in background but not returning anything",
|
||||||
|
);
|
||||||
|
throw Exception(
|
||||||
|
"Decoding image in background but not returning anything",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
final image = await img_pkg.decodeImageFile(imagePath);
|
||||||
|
final imageData = image?.data;
|
||||||
|
if (imageData == null) {
|
||||||
|
_logger.severe(
|
||||||
|
"Failed to decode image from file: $imagePath using image package",
|
||||||
|
);
|
||||||
|
throw Exception(
|
||||||
|
"Failed to decode image from file: $imagePath using image package",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
final bytes = imageData.getBytes(order: img_pkg.ChannelOrder.rgba);
|
||||||
|
final dimensions = Dimensions(
|
||||||
|
width: image!.width,
|
||||||
|
height: image.height,
|
||||||
|
);
|
||||||
|
return DecodedImage(
|
||||||
|
dimensions: dimensions,
|
||||||
|
rawRgbaBytes: bytes,
|
||||||
|
);
|
||||||
|
}
|
||||||
final imageData = await File(imagePath).readAsBytes();
|
final imageData = await File(imagePath).readAsBytes();
|
||||||
|
|
||||||
final Map<String, IfdTag> exifData = await readExifFromBytes(imageData);
|
final Map<String, IfdTag> exifData = await readExifFromBytes(imageData);
|
||||||
|
|||||||
Reference in New Issue
Block a user