{"action":"created","issue":{"url":"https://api.github.com/repos/brendan-duncan/image/issues/67","repository_url":"https://api.github.com/repos/brendan-duncan/image","labels_url":"https://api.github.com/repos/brendan-duncan/image/issues/67/labels{/name}","comments_url":"https://api.github.com/repos/brendan-duncan/image/issues/67/comments","events_url":"https://api.github.com/repos/brendan-duncan/image/issues/67/events","html_url":"https://github.com/brendan-duncan/image/issues/67","id":326837998,"number":67,"title":"Getting a `NoSuchMethodError: The getter 'exif' was called on null.` when converting a .png to .jpeg","user":{"login":"pablote","id":2463995,"avatar_url":"https://avatars2.githubusercontent.com/u/2463995?v=4","gravatar_id":"","url":"https://api.github.com/users/pablote","html_url":"https://github.com/pablote","followers_url":"https://api.github.com/users/pablote/followers","following_url":"https://api.github.com/users/pablote/following{/other_user}","gists_url":"https://api.github.com/users/pablote/gists{/gist_id}","starred_url":"https://api.github.com/users/pablote/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pablote/subscriptions","organizations_url":"https://api.github.com/users/pablote/orgs","repos_url":"https://api.github.com/users/pablote/repos","events_url":"https://api.github.com/users/pablote/events{/privacy}","received_events_url":"https://api.github.com/users/pablote/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2018-05-27T18:25:39Z","updated_at":"2018-05-27T19:10:54Z","closed_at":null,"author_association":"NONE","body":"This is my code. Image comes directly from the camera using the image_picker plugin:\r\n\r\n```\r\nvar imageFile = await ImagePicker.pickImage(source: ImageSource.camera);\r\n\r\ntry {\r\n      var pngImage = image.decodePng(imageFile.readAsBytesSync());\r\n      print(\"## Image decoded fine\");\r\n      var jpegFile = new File(path.join(tempPath, 'upload.jpg'));\r\n      print(\"## 1\");\r\n      var jpegBytes = image.encodeJpg(pngImage);\r\n      print(\"## 1B\");\r\n      jpegFile.writeAsBytesSync(jpegBytes);\r\n      print(\"## 2\");\r\n      imageFile = jpegFile;\r\n      print(\"## 3\");\r\n    } catch (error) {\r\n      print(\"## ERROR\");\r\n      print(error);\r\n      print(\"## ERROR DONE\");\r\n    }\r\n```\r\n\r\nAnd it logs to console:\r\n\r\n```\r\nI/flutter (15417): ## Camera filename/storage/emulated/0/Android/data/com.scanrapp/files/Pictures/3967201f-c26f-49db-8d04-09929bace1f21282873232.png\r\nI/flutter (15417): ## Image decoded fine\r\nI/flutter (15417): ## 1\r\nI/flutter (15417): ## ERROR\r\nI/flutter (15417): NoSuchMethodError: The getter 'exif' was called on null.\r\nI/flutter (15417): Receiver: null\r\nI/flutter (15417): Tried calling: exif\r\nI/flutter (15417): ## ERROR DONE\r\n```\r\n\r\nIf instead of `decodePng` I use `decodeImage`, then it doesn't fail. But the generated image seems invalid, I can't open it with any application.\r\n"},"comment":{"url":"https://api.github.com/repos/brendan-duncan/image/issues/comments/392357785","html_url":"https://github.com/brendan-duncan/image/issues/67#issuecomment-392357785","issue_url":"https://api.github.com/repos/brendan-duncan/image/issues/67","id":392357785,"user":{"login":"brendan-duncan","id":3642099,"avatar_url":"https://avatars1.githubusercontent.com/u/3642099?v=4","gravatar_id":"","url":"https://api.github.com/users/brendan-duncan","html_url":"https://github.com/brendan-duncan","followers_url":"https://api.github.com/users/brendan-duncan/followers","following_url":"https://api.github.com/users/brendan-duncan/following{/other_user}","gists_url":"https://api.github.com/users/brendan-duncan/gists{/gist_id}","starred_url":"https://api.github.com/users/brendan-duncan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brendan-duncan/subscriptions","organizations_url":"https://api.github.com/users/brendan-duncan/orgs","repos_url":"https://api.github.com/users/brendan-duncan/repos","events_url":"https://api.github.com/users/brendan-duncan/events{/privacy}","received_events_url":"https://api.github.com/users/brendan-duncan/received_events","type":"User","site_admin":false},"created_at":"2018-05-27T19:10:54Z","updated_at":"2018-05-27T19:10:54Z","author_association":"OWNER","body":"If you have an example image, I can debug it tonight.\n\nOn Sun, May 27, 2018 at 12:07 PM Pablo Compagni <notifications@github.com>\nwrote:\n\n> Thanks for the help, I found something new (sorry for all the back and\n> forth). ImagePicker plugin saves a .png file, but the content is actually\n> is a JPEG image (flutter/flutter#17947\n> <https://github.com/flutter/flutter/issues/17947>). So that explains de\n> decodePng returning null, and decodeImage working.\n>\n> The malformed image it's harder to reproduce I guess, I'm uploading the\n> image to a python backend and saving it as a file. I'm confident that part\n> of the code works fine, cause I have no problems with other images, only\n> the ones that go though this process. The example code might seems useless\n> now, but I'm planning on using this to reduce the size of the file before\n> uploading, so I'm still hoping this to work.\n>\n> About error messages, pythons shows this when trying to open with Pillow: broken\n> data stream when reading image file. And if it open it on my mac:\n> [image: screen shot 2018-05-27 at 4 06 48 pm]\n> <https://user-images.githubusercontent.com/2463995/40589671-fe8219f2-61c7-11e8-9149-1f17cd3613ec.png>\n>\n> —\n> You are receiving this because you commented.\n>\n>\n> Reply to this email directly, view it on GitHub\n> <https://github.com/brendan-duncan/image/issues/67#issuecomment-392357181>,\n> or mute the thread\n> <https://github.com/notifications/unsubscribe-auth/ADeS86ugcv9oSny-e1Rao1ZVHSpH0WEmks5t2vlbgaJpZM4UPYHf>\n> .\n>\n"}}
{"actor":{"display_login":"brendan-duncan"}}