Title: Request: image.to_bytes() function · Issue #25 · treeform/pixie-python · GitHub
Open Graph Title: Request: image.to_bytes() function · Issue #25 · treeform/pixie-python
X Title: Request: image.to_bytes() function · Issue #25 · treeform/pixie-python
Description: I need the bytes of the images, for example, use them in pillow or pygame. Also "imageFromBytes(data: string): Image". I've made this little library for making this feature for me, it gets the image data bytes as well the png file bytes....
Open Graph Description: I need the bytes of the images, for example, use them in pillow or pygame. Also "imageFromBytes(data: string): Image". I've made this little library for making this feature for me, it gets the imag...
X Description: I need the bytes of the images, for example, use them in pillow or pygame. Also "imageFromBytes(data: string): Image". I've made this little library for making this feature for me, it...
Opengraph URL: https://github.com/treeform/pixie-python/issues/25
X: @github
Domain: github.com
IPv4 address: 140.82.112.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Request: image.to_bytes() function","articleBody":"I need the bytes of the images, for example, use them in pillow or pygame. Also \"imageFromBytes(data: string): Image\".\r\n\r\nI've made this little library for making this feature for me, it gets the image data bytes as well the png file bytes.\r\n```nim\r\nimport\r\n nimpy,\r\n pixie\r\n\r\npyExportModule(\"pixie_utils\")\r\n\r\nproc getImageBytes*(image: Image, format: string = \"png\"): string {.raises: [PixieError].} =\r\n # Gets the bytes from image.\r\n let encodeFormat = case format:\r\n of \"png\": PngFormat\r\n of \"bmp\": BmpFormat\r\n of \"jpg\", \"jpeg\": JpegFormat\r\n of \"qoi\": QoiFormat\r\n of \"ppm\": PpmFormat\r\n else:\r\n raise newException(PixieError, \"Unsupported image format\")\r\n\r\n result = image.encodeImage(encodeFormat)\r\n\r\nproc getImageData*(image: Image): string {.raises: [].} =\r\n # Gets the image data as bytes.\r\n result = newString(image.width * image.height * 4)\r\n var\r\n i = 0\r\n rgba: ColorRGBA\r\n \r\n for color in image.data:\r\n rgba = color.rgba()\r\n result[i] = rgba.r.char\r\n result[i+1] = rgba.g.char\r\n result[i+2] = rgba.b.char\r\n result[i+3] = rgba.a.char\r\n i += 4\r\n\r\nproc getImageBytes(image_ref: int, format: string = \"png\"): string {.exportpy: \"getImageBytes\".} =\r\n result = getImageBytes(cast[Image](image_ref), format)\r\n\r\nproc getImageData(image_ref: int): string {.exportpy: \"getImageData\".} =\r\n result = getImageData(cast[Image](image_ref))\r\n```","author":{"url":"https://github.com/IagoBeuller","@type":"Person","name":"IagoBeuller"},"datePublished":"2022-12-22T06:57:59Z","url":"https://github.com/treeform/pixie-python/issues/25"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:7cb34f14-5f0d-5253-f1d9-3220daf29d3d |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9DE4:208411:BAB777:FD795A:6B048781 |
| html-safe-nonce | e9f695d4e262053aaea13db08c5c6007d079e9f1de35b711c3cdb98687f13f9d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5REU0OjIwODQxMTpCQUI3Nzc6RkQ3OTVBOjZCMDQ4NzgxIiwidmlzaXRvcl9pZCI6IjY0NDE1OTY2MDM3ODU4NDA1MTQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | cd7fe90fafcf6cf16eca974fd9cd708eb897ea8db03c0b62d7d5ebad83d804a1 |
| hovercard-subject-tag | issue:1507363524 |
| github-keyboard-shortcuts | repository,source-code,file-tree,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/treeform/pixie-python/25/issue_layout |
| twitter:image | https://opengraph.githubassets.com/c1fcee1f9941b776279d03f40640e36630e96ee771319bba4f2c142fbf7ad82e/treeform/pixie-python/issues/25 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/c1fcee1f9941b776279d03f40640e36630e96ee771319bba4f2c142fbf7ad82e/treeform/pixie-python/issues/25 |
| og:image:alt | I need the bytes of the images, for example, use them in pillow or pygame. Also "imageFromBytes(data: string): Image". I've made this little library for making this feature for me, it gets the imag... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | IagoBeuller |
| hostname | github.com |
| expected-hostname | github.com |
| None | 1d5c152376e38b7d2e37f3d5179be29a73bee93b85110da28a4eebe1159cdc70 |
| turbo-cache-control | no-preview |
| go-import | github.com/treeform/pixie-python git https://github.com/treeform/pixie-python.git |
| octolytics-dimension-user_id | 125948 |
| octolytics-dimension-user_login | treeform |
| octolytics-dimension-repository_id | 399247825 |
| octolytics-dimension-repository_nwo | treeform/pixie-python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 399247825 |
| octolytics-dimension-repository_network_root_nwo | treeform/pixie-python |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | f5017e8ff4ea25a8011fcf0f2a0e430c60dc86c8 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width