Merge branch 'krille/image' into 'main'
refactor: Use image package to resize images See merge request famedly/fluffychat!558
This commit is contained in:
commit
d23d67cb3d
8 changed files with 61 additions and 145 deletions
|
|
@ -297,12 +297,11 @@ class ChatDetailsController extends State<ChatDetails> {
|
|||
MatrixFile file;
|
||||
if (PlatformInfos.isMobile) {
|
||||
final result = await ImagePicker().pickImage(
|
||||
source: action == AvatarAction.camera
|
||||
? ImageSource.camera
|
||||
: ImageSource.gallery,
|
||||
imageQuality: 50,
|
||||
maxWidth: 1600,
|
||||
maxHeight: 1600);
|
||||
source: action == AvatarAction.camera
|
||||
? ImageSource.camera
|
||||
: ImageSource.gallery,
|
||||
imageQuality: 50,
|
||||
);
|
||||
if (result == null) return;
|
||||
file = MatrixFile(
|
||||
bytes: await result.readAsBytes(),
|
||||
|
|
|
|||
|
|
@ -26,12 +26,11 @@ class _SendFileDialogState extends State<SendFileDialog> {
|
|||
bool origImage = false;
|
||||
bool _isSending = false;
|
||||
|
||||
static const maxWidth = 1600;
|
||||
Future<void> _send() async {
|
||||
var file = widget.file;
|
||||
if (file is MatrixImageFile && !origImage) {
|
||||
try {
|
||||
file = await resizeImage(file, max: maxWidth);
|
||||
file = await file.resizeImage();
|
||||
} catch (e) {
|
||||
// couldn't resize
|
||||
}
|
||||
|
|
|
|||
|
|
@ -79,12 +79,11 @@ class SettingsController extends State<Settings> {
|
|||
MatrixFile file;
|
||||
if (PlatformInfos.isMobile) {
|
||||
final result = await ImagePicker().pickImage(
|
||||
source: action == AvatarAction.camera
|
||||
? ImageSource.camera
|
||||
: ImageSource.gallery,
|
||||
imageQuality: 50,
|
||||
maxWidth: 1600,
|
||||
maxHeight: 1600);
|
||||
source: action == AvatarAction.camera
|
||||
? ImageSource.camera
|
||||
: ImageSource.gallery,
|
||||
imageQuality: 50,
|
||||
);
|
||||
if (result == null) return;
|
||||
file = MatrixFile(
|
||||
bytes: await result.readAsBytes(),
|
||||
|
|
|
|||
|
|
@ -198,8 +198,6 @@ class EmotesSettingsController extends State<EmotesSettings> {
|
|||
});
|
||||
}
|
||||
|
||||
static const maxImageWidth = 1600;
|
||||
|
||||
void imagePickerAction(
|
||||
ValueNotifier<ImagePackImageContent> controller) async {
|
||||
final result =
|
||||
|
|
@ -210,7 +208,7 @@ class EmotesSettingsController extends State<EmotesSettings> {
|
|||
name: result.fileName,
|
||||
);
|
||||
try {
|
||||
file = await resizeImage(file, max: maxImageWidth);
|
||||
file = await file.resizeImage(calcBlurhash: false);
|
||||
} catch (_) {
|
||||
// do nothing
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue