fluttercandies / flutter_image_compress

flutter image compress
MIT License
633 stars 214 forks source link

[Request] Flip image #221

Open HE-LU opened 2 years ago

HE-LU commented 2 years ago

Hey, we need our app to flip images horizontally when saving them. Sadly I found no way to do that.

Would it make sense to add new parameters to compress methods? Or is there any other simple way to flip the image for an example from the output Uint8List?

SmearyQuill commented 10 months ago

this seems to do the trick, idk if has performance issues, you can try to specify the format to speed up some parts `
//necessary import

import 'package:image/image.dart' as imgF;

  imgF.Image? img = await imgF.decodeImageFile(imgFile.path);//read image bytes from file (there's also a bytes option)
  imgF.flip(img!, direction: imgF.FlipDirection.horizontal);//flip it
  final flipped = imgF.encodeJpg(img);//you gotta get the enoded bytes, there are many formats available
  await imgFile.writeAsBytes(flipped);//write the changes if you need 

`