{ "id": "175422", "key": "AC-6582", "fields": { "issuetype": { "id": "4", "description": "An improvement or enhancement to an existing feature or task.", "name": "Improvement", "subtask": false }, "project": { "id": "12217", "key": "AC", "name": "Appcelerator - INBOX", "projectCategory": { "id": "10000", "description": "", "name": "Customer Service" } }, "resolution": { "id": "3", "description": "The problem is a duplicate of an existing issue.", "name": "Duplicate" }, "resolutiondate": "2020-09-08T23:42:21.000+0000", "created": "2020-08-09T11:16:47.000+0000", "labels": [ "android", "exif" ], "versions": [], "issuelinks": [ { "id": "58643", "type": { "id": "10003", "name": "Relates", "inward": "relates to", "outward": "relates to" }, "inwardIssue": { "id": "175456", "key": "TIMOB-28093", "fields": { "summary": "TiAPI: Add properties \"uprightWidth\" and \"uprightHeight\" to Ti.Blob", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "priority": { "name": "Medium", "id": "3" }, "issuetype": { "id": "4", "description": "An improvement or enhancement to an existing feature or task.", "name": "Improvement", "subtask": false } } } } ], "assignee": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2020-09-08T23:42:21.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [], "description": "In Ti 9.1.0 there was a change to the orientation handling of rotated images:\r\n\r\nhttps://github.com/appcelerator/titanium_mobile/pull/11679\r\n\r\nhttps://github.com/appcelerator/titanium_mobile/blob/7ce3ae11f2c886864ed7713b1e88324b60fdf8f6/android/titanium/src/java/org/appcelerator/titanium/TiBlob.java#L756-L758\r\n\r\nwhile this fixes the rotation of the images in the example it brings some problems using av.imageview:\r\nhttps://github.com/AndreaVitale/av.imageview/issues/92\r\n\r\nOne thing I see is that on my Android 10, Pixel 4 I always get the wrong orientation in e.media.width/height for portrait images when looking at images from camera or gallery but I don't know the orientation (e.g. a portrait image is exif orientation 6 (top, right) but the returned width value is higher).\r\n\r\nIn my opinion the images that are returned to my app should always be in the correct orientation AND the width/height value should represent that too.\r\n\r\n{code}\r\nvar window = Ti.UI.createWindow({\r\n\ttitle: \"Image Test\"\r\n});\r\n\r\nvar AvImageview = require(\"av.imageview\");\r\nvar img1 =AvImageview.createImageView({\r\n\twidth: Ti.UI.FILL,\r\n\theight: 200,\r\n\ttop: 0,\r\n\tcontentMode: AvImageview.CONTENT_MODE_ASPECT_FILL,\r\n});\r\n\r\nvar img2 =AvImageview.createImageView({\r\n\twidth: Ti.UI.FILL,\r\n\theight: 200,\r\n\ttop: 200,\r\n\tcontentMode: AvImageview.CONTENT_MODE_ASPECT_FILL,\r\n});\r\nvar img3 =Ti.UI.createImageView({\r\n\twidth: Ti.UI.SIZE,\r\n\theight: 200,\r\n\ttop: 400,\r\n\tautoRotate: true\r\n});\r\nvar img4 =Ti.UI.createImageView({\r\n\twidth: Ti.UI.SIZE,\r\n\theight: 200,\r\n\ttop: 600,\r\n\tautoRotate: true\r\n});\r\nwindow.add(img1);\r\nwindow.add(img2);\r\nwindow.add(img3);\r\nwindow.add(img4);\r\nvar dl = Ti.UI.createButton({\r\n\ttitle: \"gal\",\r\n\tbottom: 60,\r\n});\r\ndl.addEventListener(\"click\", function(e) {\r\n\tTi.Media.openPhotoGallery({\r\n\t\tsuccess: function(e) {\r\n\t\t\tvar w = e.media.width;\r\n\t\t\tvar h = e.media.height;\r\n\r\n\t\t\tvar r = h / w;\r\n\t\t\tw = 1024;\r\n\t\t\th = r * w;\r\n\r\n\t\t\tvar imageBlob = e.media.imageAsResized(w, h);\r\n\t\t\timg1.image = e.media;\r\n\t\t\timg2.image = imageBlob;\r\n\t\t\timg3.image = e.media;\r\n\t\t\timg4.image = imageBlob;\r\n\t\t}\r\n\t});\r\n});\r\n\r\nwindow.add(dl);\r\nwindow.open();\r\n{code}\r\n\r\nNeeds av.imageview (https://github.com/AndreaVitale/av.imageview/releases/tag/Android-5.0.1)\r\n\r\n9.0.3.GA\r\n !ti903ga.jpg|thumbnail! \r\n\r\n9.1.0.RC\r\n !ti910rc.jpg|thumbnail! \r\n\r\n1st and 3rd image are straight from the Gallery\r\n2nd and 4th image are resized images.", "attachment": [ { "id": "67491", "filename": "ti903ga.jpg", "author": { "name": "michael", "key": "michael", "displayName": "Michael Gangolf", "active": true, "timeZone": "Europe/Berlin" }, "created": "2020-08-15T13:23:12.000+0000", "size": 368794, "mimeType": "image/jpeg" }, { "id": "67490", "filename": "ti910rc.jpg", "author": { "name": "michael", "key": "michael", "displayName": "Michael Gangolf", "active": true, "timeZone": "Europe/Berlin" }, "created": "2020-08-15T13:19:49.000+0000", "size": 447507, "mimeType": "image/jpeg" } ], "flagged": false, "summary": "Android: Image orientation handling", "creator": { "name": "michael", "key": "michael", "displayName": "Michael Gangolf", "active": true, "timeZone": "Europe/Berlin" }, "subtasks": [], "reporter": { "name": "michael", "key": "michael", "displayName": "Michael Gangolf", "active": true, "timeZone": "Europe/Berlin" }, "environment": null, "comment": { "comments": [ { "id": "456485", "author": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "body": "[~michael], the real issue is that Google's image loading APIs ignore the JPEG's EXIF orientation when decoding it to a bitmap and simply load it as-is. Apple and Microsoft will pre-rotate it, but Google does not.\r\n\r\nThe Titanium blob's \"width\" and \"height\" properties represent the actual width and height of the bitmap it wraps. In this case, it's for the unrotated image and it's technically correct. Titanium's {{ImageView.image}} property is the only image displaying API that will correctly rotate a JPEG. So, swapping the blob's width/height values would end up causing sizing issues in all of our other image displaying APIs such as \"backgroundImage\".\r\n\r\nI think a good *+interim+* solution would be to add a new \"rotation\" property to {{Ti.Blob}} which would provide the EXIF rotation. This is needed for people who are doing the math themselves, such as you. In your case, you know you need to swap width/height values when the rotation is 90 or 180 degrees.\r\n(On iOS, this new \"rotation\" property will always be zero since Apple pre-rotates it.)\r\n\r\nThe BEST solution would be for us to load JPEGs ourselves via the \"libjpeg\" library and rotate it during the decoding process, but this would involve a major refactoring of our code (although I think it needs it). If we were to do this, then the blob's \"rotation\" property will always be zero, the blob's width/height properties would be what you expect, and then we can finally be done with this nonsense.", "updateAuthor": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2020-08-17T19:01:30.000+0000", "updated": "2020-08-17T19:01:30.000+0000" }, { "id": "456486", "author": { "name": "michael", "key": "michael", "displayName": "Michael Gangolf", "active": true, "timeZone": "Europe/Berlin" }, "body": "Thank you for the great explanation! I've tested it with a js exif library, have to give it another go.\r\n\r\nit is just that the change in 9.1.0 (swapping the values for rotated images) https://github.com/appcelerator/titanium_mobile/blob/7ce3ae11f2c886864ed7713b1e88324b60fdf8f6/android/titanium/src/java/org/appcelerator/titanium/TiBlob.java#L756-L758 broke it for me and 9.0.3.GA is working. \r\nPerhaps it is a combination of that PR (since it fixes other parts) and an exif check? Here is a test image: http://migaweb.de/IMG_20200802_151801.jpg\r\n\r\nI hate handling images on Android :-D Especially on Samsung phones. ", "updateAuthor": { "name": "michael", "key": "michael", "displayName": "Michael Gangolf", "active": true, "timeZone": "Europe/Berlin" }, "created": "2020-08-17T19:14:38.000+0000", "updated": "2020-08-17T19:14:38.000+0000" }, { "id": "456489", "author": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "updateAuthor": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2020-08-17T20:04:37.000+0000", "updated": "2020-08-17T20:04:37.000+0000" }, { "id": "456521", "author": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "body": "[~michael], I'm thinking about adding new properties \"uprightWidth\" and \"uprightHeight\" to {{Ti.Blob}} which will tell you the width/height of the JPEG after it's been rotated. This should make it more convenient to use. For iOS, theses properties will always match {{width}} and {{height}} since iOS always decodes JPEGs pre-rotated.", "updateAuthor": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2020-08-20T03:33:50.000+0000", "updated": "2020-08-20T03:33:50.000+0000" }, { "id": "456535", "author": { "name": "michael", "key": "michael", "displayName": "Michael Gangolf", "active": true, "timeZone": "Europe/Berlin" }, "body": "I was trying to find a spot to do that already but wasn't successful :) And I had some problems with cleanbuild failing on 9.2.0 at the end (had to manually install it, not sure yet why) but I'll give it another go at the weekend. ", "updateAuthor": { "name": "michael", "key": "michael", "displayName": "Michael Gangolf", "active": true, "timeZone": "Europe/Berlin" }, "created": "2020-08-20T19:47:15.000+0000", "updated": "2020-08-20T19:47:15.000+0000" }, { "id": "456537", "author": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "body": "[~michael], I have something working now. I just don't \"love\" the idea of adding these 2 new properties to {{Ti.Blob}}. Ideally you shouldn't have to worry about this in Titanium... but natively you do.\r\n\r\nMaybe a better solution might be to add a method to our \"ti.imagefactory\" module. Like an {{imageGetUprightSize()}} method? I'm a bit torn on this.", "updateAuthor": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2020-08-20T20:05:55.000+0000", "updated": "2020-08-20T20:06:14.000+0000" }, { "id": "456784", "author": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Resolved by [TIMOB-28093]", "updateAuthor": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2020-09-08T23:42:15.000+0000", "updated": "2020-09-08T23:42:15.000+0000" } ], "maxResults": 7, "total": 7, "startAt": 0 } } }