I use flutter_image_compress to first compress an image then base64 encode and post to s3. I am able to decode the image in python using the below python code:
from PIL import Image
import base64
import io
msg = base64.b64decode(base64_string)
byteArray = bytearray(msg)
byteObj = bytes(byteArray)
buf = io.BytesIO(byteObj)
img = Image.open(buf)
Now, I am not a compression expert, quite don't get it but in python, how would I compress an image using the same method that flutter_image_compress uses to if I were to uncompress an image it will be of the same form that flutter_image_compress expects? I want to create images in python for flutter_image_compress to decompress.
Image libraries I use are cv2 and PIL.
Below is my Flutter code to compress
Future<Uint8List?> testCompressFile(File file) async {
var result = await FlutterImageCompress.compressWithFile(file.absolute.path,
quality: 100,
rotate: 0,
autoCorrectionAngle: true,
keepExif: true);
return result;
}