Open gregersen79 opened 7 years ago
Hi @gregersen79,
I reviewed your case and found that this behavior has been related to the ImageSource and not setting the correct metadata for the image.
While using getImage
method in Android, we create new Bitmap, however, we are not setting the imageAsset metadata to the new created Image.
In the meantime you could use asset.fileUri
for uploading the image and the imageSource for displaying the image in the app.
Another suggestion is to use native code and to get the orientation of the newly saved image. You could review the below-attached example.
asset.getImage().then((imagesource)=>{
console.log(imagesource.android)
let folder = fs.knownFolders.documents();
var downloads = android.os.Environment.getExternalStoragePublicDirectory(android.os.Environment.DIRECTORY_DCIM).toString();
let path = fs.path.join(downloads, "Test"+counter+".png");
let saved = imagesource.saveToFile(path, "png");
if(saved){
var exif = new android.media.ExifInterface(path);
console.log("---------------------Orientation----------------------");
var orientation = exif.getAttributeInt(android.media.ExifInterface.TAG_ORIENTATION, android.media.ExifInterface.ORIENTATION_NORMAL);
console.log(orientation);
}
Hope this helps
When retrieving the imagesource like this:
the image header information gets reduced, and the rotation information is lost. Our server is using the orientation information to rotate the image.
When using the approach above to upload the image, the image header information looks like this:
Luminance Table:0 Chrominance Table:0
But if I'm uploading the image directly using the asset.fileUri, the image header information looks like this:
_Chrominance Table:0 Flash:reserved Equip Model:D6603 Metering Mode:Pattern DTDigSS:371350 Thumbnail Compression:6 DTSubsec:371350 PixXDim:3840 FocalLength:4,6 Resolution Unit:2 Y Resolution:72/1 Thumbnail ResolutionX:72/1 Thumbnail ResolutionY:72/1 Exposure Bias:0/3 Software Used:23.5.A.1.291_6f1000010 DTOrig:2016:12:22 15:17:56 Orientation:6 Thumbnail Orientation:6 ISO Speed:ISO-80 JPEG InterFormat:11790 Exposure Time:0,03 JPEG InterLength:5928 Date Time:2016:12:22 15:17:56 Thumbnail Data:255 DTOrigSS:371350 Maker Note:- PixYDim:2160 Ver:- FPXVer:- Equip Make:Sony X Resolution:72/1 CompConfig:- YCbCr Positioning:1 F-Number:F/2 Thumbnail ResolutionUnit:2 Luminance Table:0 LightSource:unknown Shutter Speed:1/32 ColorSpace:1 DTDigitized:2016:12:22 15:17:56
Is there a way to maintain the header information, or at least the orientation property?