mirror of
https://github.com/immich-app/immich.git
synced 2024-11-24 08:52:28 +02:00
fix: used png instead of jpg to maintain picture quality
This commit is contained in:
parent
a37a2470a8
commit
04f2ed54e4
@ -38,7 +38,8 @@ class CropImagePage extends HookWidget {
|
||||
size: 24,
|
||||
),
|
||||
onPressed: () async {
|
||||
final croppedImage = await cropController.croppedImage();
|
||||
final croppedImage = await cropController.croppedImage(
|
||||
quality: FilterQuality.high);
|
||||
context.pushRoute(
|
||||
EditImageRoute(
|
||||
asset: asset,
|
||||
|
@ -14,6 +14,9 @@ import 'package:immich_mobile/routing/router.dart';
|
||||
import 'package:immich_mobile/providers/album/album.provider.dart';
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:path/path.dart' as p;
|
||||
import 'dart:async';
|
||||
import 'dart:ui' as ui;
|
||||
import 'package:flutter/rendering.dart';
|
||||
|
||||
/// A stateless widget that provides functionality for editing an image.
|
||||
///
|
||||
@ -39,16 +42,18 @@ class EditImagePage extends ConsumerWidget {
|
||||
final Completer<Uint8List> completer = Completer();
|
||||
image.image.resolve(const ImageConfiguration()).addListener(
|
||||
ImageStreamListener(
|
||||
(ImageInfo info, bool _) {
|
||||
info.image
|
||||
.toByteData(format: ImageByteFormat.png)
|
||||
.then((byteData) {
|
||||
(ImageInfo info, bool _) async {
|
||||
try {
|
||||
final ByteData? byteData =
|
||||
await info.image.toByteData(format: ui.ImageByteFormat.png);
|
||||
if (byteData != null) {
|
||||
completer.complete(byteData.buffer.asUint8List());
|
||||
} else {
|
||||
completer.completeError('Failed to convert image to bytes');
|
||||
}
|
||||
});
|
||||
} catch (e) {
|
||||
completer.completeError('Error converting image: $e');
|
||||
}
|
||||
},
|
||||
onError: (exception, stackTrace) =>
|
||||
completer.completeError(exception),
|
||||
@ -65,9 +70,12 @@ class EditImagePage extends ConsumerWidget {
|
||||
) async {
|
||||
try {
|
||||
final Uint8List imageData = await _imageToUint8List(image);
|
||||
// Use PNG format for lossless quality
|
||||
final String fileName =
|
||||
"${p.withoutExtension(asset.fileName)}_edited.png";
|
||||
await ref.read(fileMediaRepositoryProvider).saveImage(
|
||||
imageData,
|
||||
title: "${p.withoutExtension(asset.fileName)}_edited.jpg",
|
||||
title: fileName,
|
||||
);
|
||||
await ref.read(albumProvider.notifier).getDeviceAlbums();
|
||||
Navigator.of(context).popUntil((route) => route.isFirst);
|
||||
|
Loading…
Reference in New Issue
Block a user