{"action":"created","issue":{"url":"https://api.github.com/repos/Hammerspoon/hammerspoon/issues/954","repository_url":"https://api.github.com/repos/Hammerspoon/hammerspoon","labels_url":"https://api.github.com/repos/Hammerspoon/hammerspoon/issues/954/labels{/name}","comments_url":"https://api.github.com/repos/Hammerspoon/hammerspoon/issues/954/comments","events_url":"https://api.github.com/repos/Hammerspoon/hammerspoon/issues/954/events","html_url":"https://github.com/Hammerspoon/hammerspoon/issues/954","id":171848824,"number":954,"title":"hs.pasteboard.readImage() cannot be opened / displayed","user":{"login":"skamsie","id":7014744,"avatar_url":"https://avatars.githubusercontent.com/u/7014744?v=3","gravatar_id":"","url":"https://api.github.com/users/skamsie","html_url":"https://github.com/skamsie","followers_url":"https://api.github.com/users/skamsie/followers","following_url":"https://api.github.com/users/skamsie/following{/other_user}","gists_url":"https://api.github.com/users/skamsie/gists{/gist_id}","starred_url":"https://api.github.com/users/skamsie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/skamsie/subscriptions","organizations_url":"https://api.github.com/users/skamsie/orgs","repos_url":"https://api.github.com/users/skamsie/repos","events_url":"https://api.github.com/users/skamsie/events{/privacy}","received_events_url":"https://api.github.com/users/skamsie/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-08-18T08:46:08Z","updated_at":"2016-08-18T18:04:49Z","closed_at":null,"body":"The ```hs.image``` returned by `readImage()` cannot be opened or saved as a regular image file. \r\n\r\nCopy an image file on your computer using the keyboard or mouse and then in the console:\r\n\r\n```\r\n> pic = hs.pasteboard.readImage()\r\n> hs.inspect(pic)\r\n<userdata 1> -- hs.image:  (0x7fa41b017e28)\r\n> pic:saveToFile('/tmp/1.jpg')\r\ntrue\r\n```\r\n\r\nOpen the image on the computer:\r\n\r\n![screen shot 2016-08-18 at 10 42 59 am](https://cloud.githubusercontent.com/assets/7014744/17767575/c661cc74-6530-11e6-8ebe-4102a79c82e9.png)\r\n\r\n\r\nThe same happens if you try to display the image or add it to a chooser window\r\n"},"comment":{"url":"https://api.github.com/repos/Hammerspoon/hammerspoon/issues/comments/240806250","html_url":"https://github.com/Hammerspoon/hammerspoon/issues/954#issuecomment-240806250","issue_url":"https://api.github.com/repos/Hammerspoon/hammerspoon/issues/954","id":240806250,"user":{"login":"asmagill","id":8139480,"avatar_url":"https://avatars.githubusercontent.com/u/8139480?v=3","gravatar_id":"","url":"https://api.github.com/users/asmagill","html_url":"https://github.com/asmagill","followers_url":"https://api.github.com/users/asmagill/followers","following_url":"https://api.github.com/users/asmagill/following{/other_user}","gists_url":"https://api.github.com/users/asmagill/gists{/gist_id}","starred_url":"https://api.github.com/users/asmagill/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/asmagill/subscriptions","organizations_url":"https://api.github.com/users/asmagill/orgs","repos_url":"https://api.github.com/users/asmagill/repos","events_url":"https://api.github.com/users/asmagill/events{/privacy}","received_events_url":"https://api.github.com/users/asmagill/received_events","type":"User","site_admin":false},"created_at":"2016-08-18T18:04:49Z","updated_at":"2016-08-18T18:04:49Z","body":"If you are selecting a file on your computer in the Finder and then selecting \"Copy...\" from the Edit menu, then this is the expected behavior -- what is being put on the clipboard is a file URL reference, an icon for the file URL reference, and the text of the file's name (see `hs.inspect(hs.pasteboard.allContentTypes())`).\r\n\r\nIf you're wanting to see the contents of the file, you should either load it with `hs.image.imageFromPath(\"/path/to/file.jpeg\")`, pull the file path from the file URL reference with something like `hs.image.imageFromPath(hs.pasteboard.readURL():match(\"^file://(.*)$\"))`, or open it up in an application like Preview, select the entire image (\"Select All\" in the Edit menu) and then copy it to the clipboard (\"Copy\" in the Edit menu).  Then `hs.pasteboard.readImage()` will work as I think you're expecting."}}
{"actor":{"display_login":"asmagill"}}