Flutter camera image picker has a known issue of returning images with wrong unexpected rotation. The issue has been raised in the GitHub and marked as closed, but still occurs in the latest stable release. The issue can, however, be resolved easily with the help of exif-rotation plugin. This issue is known to be affecting both iOS and Android platforms.
Why the image is rotated
When we take an image from the camera, we could be holding the phone in any orientation. Sometimes we take photos in landscape mode, sometimes portait and so on. The camera app takes the photo and adds special metadata entries (EXIF data) to the file so that it can be rotated properly in image viewers.
Flutter image_picker has a bug where it doesn’t process the image with the given EXIF data which makes the image appear in the wrong rotation. However, we can fix it by considering the EXIF data and rotating the image manually as the metadata suggests.
How to fix the rotation?
To fix the unwanted image rotation, we need to rotate the image based on the metadata available. Luckily, a library named flutter_exif_rotation is available. Once the image is taken from the image-picker, give it to the FlutterExifRotation library. The library will rotate it, if needed, based on the available EXIF data.
Let’s have a look into the sample code.
Firstly, add the flutter_exif_rotation library to your pubspec.yaml file.
dependencies: ... flutter_exif_rotation: ^0.5.1 ...
Sample code for image pick and rotation fix
import 'dart:async'; import 'dart:io'; import 'package:flutter_exif_rotation/flutter_exif_rotation.dart'; //EXIF rotation library import 'package:image_picker/image_picker.dart'; //Image picker library class CameraService { Future<XFile?> pickImage() async { //Take a photo from camera final XFile? image = await ImagePicker().pickImage( source: ImageSource.camera, maxWidth: 1200, maxHeight: 1200, requestFullMetadata: true ); if (image != null) { // Rotate the image to fix the wrong rotation coming from ImagePicker File rotatedImage = await FlutterExifRotation.rotateImage(path: image.path); return XFile(rotatedImage.path); //Return the file } return image; } }
In the above code, The function FlutterExifRotation#rotateImage will fix the rotation of the image by considering the EXIF orientation tags. This solution has been proposed in the GitHub and many people supported this as the best way available at the moment.
If you have liked this article, you might also like other Fltuter tutorials I have written.
… [Trackback]
[…] Read More Info here to that Topic: genuinecoder.com/flutter-camera-image-orientation-rotation-issue-fix/ […]
… [Trackback]
[…] Here you will find 64163 additional Info on that Topic: genuinecoder.com/flutter-camera-image-orientation-rotation-issue-fix/ […]
… [Trackback]
[…] Here you will find 48503 more Information to that Topic: genuinecoder.com/flutter-camera-image-orientation-rotation-issue-fix/ […]
… [Trackback]
[…] Info to that Topic: genuinecoder.com/flutter-camera-image-orientation-rotation-issue-fix/ […]
… [Trackback]
[…] Read More Info here on that Topic: genuinecoder.com/flutter-camera-image-orientation-rotation-issue-fix/ […]
… [Trackback]
[…] Find More here to that Topic: genuinecoder.com/flutter-camera-image-orientation-rotation-issue-fix/ […]
… [Trackback]
[…] Read More to that Topic: genuinecoder.com/flutter-camera-image-orientation-rotation-issue-fix/ […]
… [Trackback]
[…] Read More on that Topic: genuinecoder.com/flutter-camera-image-orientation-rotation-issue-fix/ […]
… [Trackback]
[…] Find More here to that Topic: genuinecoder.com/flutter-camera-image-orientation-rotation-issue-fix/ […]
… [Trackback]
[…] Find More here on that Topic: genuinecoder.com/flutter-camera-image-orientation-rotation-issue-fix/ […]
… [Trackback]
[…] Find More Information here on that Topic: genuinecoder.com/flutter-camera-image-orientation-rotation-issue-fix/ […]
… [Trackback]
[…] Read More on that Topic: genuinecoder.com/flutter-camera-image-orientation-rotation-issue-fix/ […]
… [Trackback]
[…] Find More on to that Topic: genuinecoder.com/flutter-camera-image-orientation-rotation-issue-fix/ […]
… [Trackback]
[…] Information on that Topic: genuinecoder.com/flutter-camera-image-orientation-rotation-issue-fix/ […]
… [Trackback]
[…] Information to that Topic: genuinecoder.com/flutter-camera-image-orientation-rotation-issue-fix/ […]
… [Trackback]
[…] Read More here on that Topic: genuinecoder.com/flutter-camera-image-orientation-rotation-issue-fix/ […]
… [Trackback]
[…] Info to that Topic: genuinecoder.com/flutter-camera-image-orientation-rotation-issue-fix/ […]
… [Trackback]
[…] Information on that Topic: genuinecoder.com/flutter-camera-image-orientation-rotation-issue-fix/ […]
… [Trackback]
[…] Find More to that Topic: genuinecoder.com/flutter-camera-image-orientation-rotation-issue-fix/ […]
… [Trackback]
[…] Info on that Topic: genuinecoder.com/flutter-camera-image-orientation-rotation-issue-fix/ […]
… [Trackback]
[…] Info to that Topic: genuinecoder.com/flutter-camera-image-orientation-rotation-issue-fix/ […]
… [Trackback]
[…] Find More on to that Topic: genuinecoder.com/flutter-camera-image-orientation-rotation-issue-fix/ […]
… [Trackback]
[…] Read More here to that Topic: genuinecoder.com/flutter-camera-image-orientation-rotation-issue-fix/ […]
… [Trackback]
[…] Find More on that Topic: genuinecoder.com/flutter-camera-image-orientation-rotation-issue-fix/ […]
… [Trackback]
[…] Information to that Topic: genuinecoder.com/flutter-camera-image-orientation-rotation-issue-fix/ […]
… [Trackback]
[…] Read More Information here on that Topic: genuinecoder.com/flutter-camera-image-orientation-rotation-issue-fix/ […]
… [Trackback]
[…] Find More here to that Topic: genuinecoder.com/flutter-camera-image-orientation-rotation-issue-fix/ […]
… [Trackback]
[…] Info to that Topic: genuinecoder.com/flutter-camera-image-orientation-rotation-issue-fix/ […]
… [Trackback]
[…] Find More Info here on that Topic: genuinecoder.com/flutter-camera-image-orientation-rotation-issue-fix/ […]
… [Trackback]
[…] Info to that Topic: genuinecoder.com/flutter-camera-image-orientation-rotation-issue-fix/ […]
… [Trackback]
[…] Here you can find 95751 additional Information on that Topic: genuinecoder.com/flutter-camera-image-orientation-rotation-issue-fix/ […]
… [Trackback]
[…] Read More on that Topic: genuinecoder.com/flutter-camera-image-orientation-rotation-issue-fix/ […]
… [Trackback]
[…] Find More on that Topic: genuinecoder.com/flutter-camera-image-orientation-rotation-issue-fix/ […]
… [Trackback]
[…] Read More here on that Topic: genuinecoder.com/flutter-camera-image-orientation-rotation-issue-fix/ […]
… [Trackback]
[…] Read More Information here on that Topic: genuinecoder.com/flutter-camera-image-orientation-rotation-issue-fix/ […]
[…] buy rybelsus […]
[…] order clomid online […]
[…] buy 5mg cialis online […]
[…] cialis no prescription […]
[…] how much does 50 mg viagra cost […]
[…] inseng root benefits for men […]
kamagra en ligne sans ordonnance du jour au lendemain
kamagra medicament fonts prescrire
buying enclomiphene buy online canada
how to order enclomiphene overnight no rx
how to buy androxal buy san francisco
get androxal purchase toronto
ordering dutasteride without rx online
how to buy dutasteride usa where to buy
how to buy flexeril cyclobenzaprine australia no prescription
buy flexeril cyclobenzaprine buy in the uk
cheapest buy gabapentin generic available in united states
gabapentin non prescription
buy cheap fildena generic uk next day delivery
how to order fildena buy uk no prescription
get itraconazole australia generic online
buy itraconazole in London
best staxyn price
Online staxyn no perscription
discount avodart generic uk
order avodart generic cheap
buy cheap rifaximin generic best price
how to order rifaximin generic name
order xifaxan on line
buy xifaxan without rx online
dalナ。テュ den dodテ。nテュ kamagra bez skriptu
kanada kamagra neobecná
[…] how much is generic cialis […]
[…] cialis professional […]
[…] brand cialis […]
[…] roman cialis cost […]
[…] costco cialis […]
[…] cialis canada pharmacy […]
[…] sildenafil citrate 100mg en español […]
[…] cialis 5 mg […]