작성일 : 21.10.08
Flutter Version : 2.2.3
// 사용 패키지 import
import 'package:image/image.dart' as img;
// 함수 정의
Future<File> rotateImage(String path) async {
final originalFile = File(path);
List<int> imageBytes = await originalFile.readAsBytes();
final originalImage = img.decodeImage(imageBytes);
img.Image fixedImage;
fixedImage = img.copyRotate(originalImage!, 90); // 90도 회전
fixedImage = img.flipHorizontal(fixedImage); // 좌우 반전
final fixedFile = await originalFile.writeAsBytes(img.encodeJpg(fixedImage)); // JPG 형태로 File 저장
return fixedFile;
}