{ "id": "154683", "key": "TIMOB-20319", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [ { "id": "16980", "description": "New V8", "name": "Release 6.0.0", "archived": false, "released": true, "releaseDate": "2016-11-15" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2016-09-05T03:13:32.000+0000", "created": "2016-02-03T12:47:50.000+0000", "priority": { "name": "Critical", "id": "1" }, "labels": [], "versions": [ { "id": "17072", "name": "Release 5.1.2", "archived": false, "released": true, "releaseDate": "2016-01-12" } ], "issuelinks": [ { "id": "52370", "type": { "id": "10003", "name": "Relates", "inward": "relates to", "outward": "relates to" }, "inwardIssue": { "id": "78626", "key": "TIMOB-4865", "fields": { "summary": "iOS: imageAsCropped rotates image", "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": "Low", "id": "4" }, "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false } } } } ], "assignee": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "updated": "2016-09-27T21:31:05.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": [ { "id": "10206", "name": "iOS", "description": "iOS Platform" } ], "description": "h6.Description\r\nSimply run the following code in a default mobile app.\r\nBasically, the test case is 1. open a camera 2. capture a image 3. crop the image from step 2 (based on the layout of UI).\r\n\r\nh6.Expect Result:\r\nThe result image should be the same like inside the red rectangle area\r\n\r\nh6. Actual Result:\r\nThe result image is not as expected, and the orientation is wrong as well. \r\n\r\nh6. Code\r\n{code}\r\nvar cameraOverLayColor = '#96000000';\r\nvar imageView;\r\nvar responseImg;\r\nvar width, height, x, y;\r\n\r\nvar win = Titanium.UI.createWindow({\r\n\tbackgroundColor:'white',\r\n\ttheme:'Theme.AppCompat.NoTitleBar',\r\n\tlayout:'vertical'\r\n});\r\n\r\nwin.open();\r\n\r\nvar cameraLbl = Ti.UI.createLabel({\r\n\ttop:20,\r\n\tcolor:'blue',\r\n\ttext: 'Open Camera',\r\n\twidth : Ti.UI.SIZE,\r\n\theight : Ti.UI.SIZE\r\n});\r\nwin.add(cameraLbl);\r\n\r\ncameraLbl.addEventListener('click',doCamera);\r\n\r\nvar mainContainer = Titanium.UI.createView();\r\n\r\nvar scanner = Titanium.UI.createView({\r\n\ttop : '5%',\r\n\twidth : '80%',\r\n\theight : '85%',\r\n\tborderColor : 'red',\r\n\tborderWidth : 5,\r\n\tborderRadius : 1\r\n});\r\n\r\nvar leftView = Ti.UI.createView({\r\n\tleft:0,\r\n\tbackgroundColor:cameraOverLayColor,\r\n\twidth : '10%',\r\n\theight : '100%' \r\n});\r\n\r\nvar rightView = Ti.UI.createView({\r\n\tright:0,\r\n\tbackgroundColor:cameraOverLayColor,\r\n\twidth : '10%',\r\n\theight : '100%' \r\n});\r\n\r\nvar topView = Ti.UI.createView({\r\n\ttop:0,\r\n\tbackgroundColor:cameraOverLayColor,\r\n\twidth : '80%',\r\n\theight :'5%'\r\n});\r\n\r\nvar bottomView = Ti.UI.createView({\r\n\tbottom:0,\r\n\tbackgroundColor:cameraOverLayColor,\r\n\twidth : '80%',\r\n\theight :'10%'\r\n});\r\n\r\nmainContainer.add(leftView);\r\nmainContainer.add(rightView);\r\nmainContainer.add(topView);\r\nmainContainer.add(bottomView);\r\nmainContainer.add(scanner);\r\n\r\n\r\nvar takeButton = Titanium.UI.createButton({\r\n\tcolor : '#fff',\r\n\tleft: 0,\r\n\tfont : {\r\n\t\tfontSize : 20,\r\n\t\tfontWeight : 'bold',\r\n\t},\r\n\ttitle : 'Take Picture'\r\n});\r\n\r\nvar cancelButton = Titanium.UI.createButton({\r\n\tcolor : '#fff',\r\n\tright: 0,\r\n\tfont : {\r\n\t\tfontSize : 20,\r\n\t\tfontWeight : 'bold',\r\n\t},\r\n\ttitle : 'Cancel'\r\n});\r\n\r\nbottomView.add(takeButton);\r\nbottomView.add(cancelButton);\r\n\r\ntakeButton.addEventListener('click', function() {\r\n\tscanner.borderColor = 'blue';\r\n\tTi.Media.takePicture();\r\n});\r\n\r\ncancelButton.addEventListener('click', function() {\r\n\tTi.Media.hideCamera();\r\n});\r\n\r\n\r\nfunction doCamera(){\t\r\n\tTitanium.Media.showCamera({\r\n\t\tsaveToPhotoGallery : false,\r\n\t\t\r\n\t\tsuccess : function(event) {\r\n\t\t\tif (event.media) {\r\n\t\t\t\tresponseImg = event.media;\r\n\t\t\t\t\r\n\t\t\t\tTi.API.info(responseImg.getWidth());\r\n\t\t\t\tTi.API.info(responseImg.getheight());\r\n\t\t\t\t\r\n\t\t\t\t// get detail CroppedDict\r\n\t\t\t\twidth = responseImg.getWidth() * 0.8;\r\n\t\t\t\theight = responseImg.getheight() * 0.85;\r\n\t\t\t\tx = responseImg.getWidth() * 0.1;\r\n\t\t\t\ty = responseImg.getheight() * 0.05;\r\n\t\t\t\t\r\n\t\t\t\tTi.API.info(width);\r\n\t\t\t\tTi.API.info(height);\r\n\t\t\t\tTi.API.info(x);\r\n\t\t\t\tTi.API.info(y);\r\n\t\t\t\t\r\n\t\t\t\tresponseImg = responseImg.imageAsCropped({width: height, height: width, x: x, y: y});\r\n\r\n\t\t\t\tif(!imageView){\r\n\t\t\t\t\timageView = Ti.UI.createImageView({\r\n\t\t\t\t\t\timage : responseImg,\r\n\t\t\t\t\t\tautorotate: true,\r\n\t\t\t\t\t\twidth : Ti.UI.SiZE,\r\n\t\t\t\t\t\theight : Ti.UI.SIZE\r\n\t\t\t\t});\r\n\t\t\t\twin.add(imageView);\r\n\t\t\t}else{\r\n\t\t\t\tTi.API.info(\"error\");\r\n\t\t\t}\r\n\r\n\t\t\tTi.Media.saveToPhotoGallery(responseImg,{\r\n\t\t\t\tsuccess: function(e) {\r\n\t\t\t\t\tTitanium.UI.createAlertDialog({\r\n \t\t\t\t\tbuttonNames : ['OK'],\r\n \t\t\t\ttitle:'Photo Gallery',\r\n \t\t\t\tmessage:'Check your photo gallery for image.'\r\n \t\t\t\t}).show(); \r\n\t\t\t\t},\r\n\t\t\t\terror: function(e) {\r\n \t\t\t\tTitanium.UI.createAlertDialog({\r\n \t\t\t\t\tbuttonNames : ['OK'],\r\n \t\t\t\ttitle:'Error saving',\r\n \t\t\t\tmessage:e.error\r\n \t\t\t\t}).show();\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t\t}else{\r\n\t\t\t\tTitanium.UI.createAlertDialog({\r\n\t\t\t\t\ttitle : 'Camera',\r\n\t\t\t\t\tmessage:'Unexpected error',\r\n\t\t\t\t\tbuttonNames : [\"OK\"]\r\n\t\t\t\t}).show();\r\n\t\t\t}\r\n\t\t\tscanner.borderColor = 'red';\r\n\t\t},\r\n\r\n\t\tcancel : function() {\r\n\t\t},\r\n\t\r\n\t\terror : function(error) {\r\n\t\t\tvar a = Titanium.UI.createAlertDialog({\r\n\t\t\t\ttitle : 'Camera'\r\n\t\t\t});\r\n\t\t\r\n\t\t\tif (error.code == Titanium.Media.NO_CAMERA) {\r\n\t\t\t\ta.setMessage('Please run this test on device');\r\n\t\t\t} else {\r\n\t\t\t\ta.setMessage('Unexpected error: ' + error.code);\r\n\t\t\t}\r\n\t\t\ta.show();\r\n\t\t},\r\n\r\n\t\toverlay : mainContainer,\r\n\t\tshowControls : false, \r\n\t\tmediaTypes : Ti.Media.MEDIA_TYPE_PHOTO,\r\n\t\tautohide : true \r\n\t});\r\n}\r\n{code}", "attachment": [], "flagged": false, "summary": "iOS: Weird behavior after crop the image captured from camera", "creator": { "name": "sliang", "key": "sliang", "displayName": "Shuo Liang", "active": true, "timeZone": "Asia/Harbin" }, "subtasks": [], "reporter": { "name": "sliang", "key": "sliang", "displayName": "Shuo Liang", "active": true, "timeZone": "Asia/Harbin" }, "environment": "TI SDK 5.1.2\r\nIOS 9.2", "closedSprints": [ { "id": 704, "state": "closed", "name": "2016 Sprint 18 SDK", "startDate": "2016-08-27T00:18:36.960Z", "endDate": "2016-09-10T00:18:00.000Z", "completeDate": "2016-09-09T20:26:13.865Z", "originBoardId": 114 } ], "comment": { "comments": [ { "id": "377614", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "Before I do further investigations, did you make sure it does not happen from using {{getheight}} instead of {{getHeight}} ?", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2016-02-23T07:58:44.000+0000", "updated": "2016-02-23T07:58:44.000+0000" }, { "id": "377616", "author": { "name": "sliang", "key": "sliang", "displayName": "Shuo Liang", "active": true, "timeZone": "Asia/Harbin" }, "body": "Any difference? Also I print out the Ti.API.info(responseImg.getheight()); And the result seems all right.", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2016-02-23T08:06:00.000+0000", "updated": "2016-02-23T16:42:05.000+0000" }, { "id": "377649", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "Ok. Does ist work properly on Android? Trying to troubleshoot as much as possible beforehand.", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2016-02-23T16:41:45.000+0000", "updated": "2016-02-23T16:41:45.000+0000" }, { "id": "377867", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "Ok, some more infos and questions:\r\n- The problems looks to happen inside the {{imageAsCropped}} method, not directly from the camera\r\n- Did it work with previous SDK versions?\r\n\r\nCan you confirm that? I will now create a simplified test case to crop a view to make the debug more easy.\r\n\r\n*Update:* Check [this demo|https://gist.github.com/hansemannn/cd11ccac9243ebe1b8ec] and [this output|http://abload.de/img/simulatorscreenshot2559rv8.png]. What is very interesting: The {{x}} and {{y}} coordinated define the center inside the origin, not the offset to create the rect. So if you set the width relative to the new width and height (40% and 42,5%), it should work pretty well.", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2016-02-25T11:29:37.000+0000", "updated": "2016-02-25T11:43:52.000+0000" }, { "id": "395301", "author": { "name": "cng", "key": "cng", "displayName": "Chee Kiat Ng", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Issue was fixed in related ticket for 6.0.0.", "updateAuthor": { "name": "cng", "key": "cng", "displayName": "Chee Kiat Ng", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2016-09-05T03:13:47.000+0000", "updated": "2016-09-05T03:13:47.000+0000" }, { "id": "397430", "author": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Verified with all three attached code samples that the feature is behaving as expected. Verified with;\r\nNPM Version: 2.15.9\r\nNode Version: 4.5.0\r\nMac OS: 10.11.6\r\nAppc CLI: 5.5.0\r\nAppc CLI NPM: 4.2.7\r\nTitanium SDK version: 6.0.0.v20160927062927\r\nAppcelerator Studio, build: 4.7.1.201609100950\r\nXcode 8.0 GM", "updateAuthor": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2016-09-27T21:30:28.000+0000", "updated": "2016-09-27T21:30:28.000+0000" } ], "maxResults": 15, "total": 15, "startAt": 0 } } }