{"action":"created","issue":{"url":"https://api.github.com/repos/nesk/puphpeteer/issues/17","repository_url":"https://api.github.com/repos/nesk/puphpeteer","labels_url":"https://api.github.com/repos/nesk/puphpeteer/issues/17/labels{/name}","comments_url":"https://api.github.com/repos/nesk/puphpeteer/issues/17/comments","events_url":"https://api.github.com/repos/nesk/puphpeteer/issues/17/events","html_url":"https://github.com/nesk/puphpeteer/issues/17","id":349520222,"node_id":"MDU6SXNzdWUzNDk1MjAyMjI=","number":17,"title":"Return string data from a screenshot","user":{"login":"jonnywilliamson","id":2513663,"node_id":"MDQ6VXNlcjI1MTM2NjM=","avatar_url":"https://avatars1.githubusercontent.com/u/2513663?v=4","gravatar_id":"","url":"https://api.github.com/users/jonnywilliamson","html_url":"https://github.com/jonnywilliamson","followers_url":"https://api.github.com/users/jonnywilliamson/followers","following_url":"https://api.github.com/users/jonnywilliamson/following{/other_user}","gists_url":"https://api.github.com/users/jonnywilliamson/gists{/gist_id}","starred_url":"https://api.github.com/users/jonnywilliamson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonnywilliamson/subscriptions","organizations_url":"https://api.github.com/users/jonnywilliamson/orgs","repos_url":"https://api.github.com/users/jonnywilliamson/repos","events_url":"https://api.github.com/users/jonnywilliamson/events{/privacy}","received_events_url":"https://api.github.com/users/jonnywilliamson/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-08-10T13:41:34Z","updated_at":"2018-08-11T05:25:38Z","closed_at":null,"author_association":"NONE","body":"Hi, I've just started to use puphpeteer and its working very nicely. Thank you for the library.\r\n\r\nI do have one query regarding how to get data back from the `screenshot` method if I do NOT wish to save it to a file.\r\n\r\nAt the moment to get a screenshot your docs say:\r\n\r\n```php\r\nuse Nesk\\Puphpeteer\\Puppeteer;\r\n\r\n$puppeteer = new Puppeteer;\r\n$browser = $puppeteer->launch();\r\n\r\n$page = $browser->newPage();\r\n$page->goto('https://example.com');\r\n$page->screenshot(['path' => 'example.png']);\r\n\r\n$browser->close();\r\n```\r\n\r\n\r\nTaking a look at the API docs over on the puppeteer site:\r\n\r\nhttps://pptr.dev/#?product=Puppeteer&version=v1.6.2&show=api-pagescreenshotoptions\r\n\r\n![image](https://user-images.githubusercontent.com/2513663/43960772-f98de700-9caa-11e8-9d3b-39fe8a1434cd.png)\r\n\r\n\r\nI would like to be able to grab a base64 (or binary) string of the image received and process it directly rather than have to save it to disk.\r\n\r\nWould there be anyway to do that at the moment, say something like this:\r\n\r\n```php\r\nuse Nesk\\Puphpeteer\\Puppeteer;\r\n\r\n$puppeteer = new Puppeteer;\r\n$browser = $puppeteer->launch();\r\n\r\n$page = $browser->newPage();\r\n$page->goto('https://example.com');\r\n$imageString = $page->screenshot(['encoding' => 'base64']);\r\n\r\n//Do things with $imageString without having to worry about a file saved on disk\r\n\r\n$browser->close();\r\n```\r\n\r\nAt the moment I can't find a way to get any data out of the `BasicResource` object that gets returned from `->screenshot`\r\n\r\nThank you!"},"comment":{"url":"https://api.github.com/repos/nesk/puphpeteer/issues/comments/412252130","html_url":"https://github.com/nesk/puphpeteer/issues/17#issuecomment-412252130","issue_url":"https://api.github.com/repos/nesk/puphpeteer/issues/17","id":412252130,"node_id":"MDEyOklzc3VlQ29tbWVudDQxMjI1MjEzMA==","user":{"login":"jonnywilliamson","id":2513663,"node_id":"MDQ6VXNlcjI1MTM2NjM=","avatar_url":"https://avatars1.githubusercontent.com/u/2513663?v=4","gravatar_id":"","url":"https://api.github.com/users/jonnywilliamson","html_url":"https://github.com/jonnywilliamson","followers_url":"https://api.github.com/users/jonnywilliamson/followers","following_url":"https://api.github.com/users/jonnywilliamson/following{/other_user}","gists_url":"https://api.github.com/users/jonnywilliamson/gists{/gist_id}","starred_url":"https://api.github.com/users/jonnywilliamson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonnywilliamson/subscriptions","organizations_url":"https://api.github.com/users/jonnywilliamson/orgs","repos_url":"https://api.github.com/users/jonnywilliamson/repos","events_url":"https://api.github.com/users/jonnywilliamson/events{/privacy}","received_events_url":"https://api.github.com/users/jonnywilliamson/received_events","type":"User","site_admin":false},"created_at":"2018-08-11T05:25:38Z","updated_at":"2018-08-11T05:25:38Z","author_association":"NONE","body":"@quocthinh212 Hi\r\n\r\nYeah absolutely I could do that, quick temporary file, read contents, do something, check the file is still there, delete the file if it still exists, ensure I catch any errors during that entire process etc etc.\r\n\r\nBut I was wondering and hoping I could just get the data directly from the `->screenshot` method and process it the way I would like to without all that hassle.\r\n\r\nI'd even settle for the php://stream object that contains the data. I have had a look and it appears it's likely held in one of these streams:\r\n\r\n![image](https://user-images.githubusercontent.com/2513663/43988513-4bcccbe2-9d2f-11e8-9bc3-6e0d24e2abb6.png)\r\n\r\n\r\nBut I have no idea at the moment the best way to get access to that, or if it's even possible.\r\n\r\nThank you"}}
{"actor":{"display_login":"jonnywilliamson"}}