{"id":15723396,"url":"https://github.com/slainless/digides-ogimaker","last_synced_at":"2025-05-05T22:29:50.687Z","repository":{"id":249331002,"uuid":"830928356","full_name":"slainless/digides-ogimaker","owner":"slainless","description":"A Cloudflare worker to generate OpenGraph banner, configured specifically for Digital Desa Profile Website.","archived":false,"fork":false,"pushed_at":"2024-07-20T12:22:01.000Z","size":2680,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-31T00:17:23.501Z","etag":null,"topics":["cloudflare","cloudflare-worker","golang","hono","image-generation","image-manipulation","image-processing","ogimage","wasi","wasm","worker"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/slainless.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-19T09:40:21.000Z","updated_at":"2025-01-14T06:15:24.000Z","dependencies_parsed_at":"2024-10-24T17:47:12.033Z","dependency_job_id":null,"html_url":"https://github.com/slainless/digides-ogimaker","commit_stats":null,"previous_names":["slainless/digides-ogimaker"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slainless%2Fdigides-ogimaker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slainless%2Fdigides-ogimaker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slainless%2Fdigides-ogimaker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slainless%2Fdigides-ogimaker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/slainless","download_url":"https://codeload.github.com/slainless/digides-ogimaker/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252585899,"owners_count":21772221,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cloudflare","cloudflare-worker","golang","hono","image-generation","image-manipulation","image-processing","ogimage","wasi","wasm","worker"],"created_at":"2024-10-03T22:11:30.086Z","updated_at":"2025-05-05T22:29:50.651Z","avatar_url":"https://github.com/slainless.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# digides-ogimaker\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"./assets/example.jpeg\" width=\"80%\"/\u003e\n\u003c/p\u003e\n\n`digides-ogimaker` (Digital Desa OG Image Maker), a cloudflare worker to generate OpenGraph banner, \nconfigured specifically for Digital Desa Profile Website.\n\nUsing Hono for edge framework, while Go is used to draw the image.\n\nLive at https://og-image-generator.digital-desa.workers.dev/.\n\n[Click here to view render example.](https://og-image-generator.digital-desa.workers.dev/?d=JfDxtkTsSNXx8lDF4BqMVcHUla4WE59lF6SeUCmRr61FvhaaPrmDfkz41Zt0C1lUKGX0X-ywirXMyPLTW78arco6dyhnnIl4OWgi6g1Evf8rFSh6iMrn1OPB7U7OKAb7-2lLFa5RfmmmAQ2U9wrtIn5EHVFGi8jnrUewocOO5vK2pdSxXaFJnSlM47ULN3fHxuqnYGdi0KT7RjyZ7et1ZAOzA-GD9PZTLhZBlc-H48FOIx9zmLo-E8UBacdm3hHDKXUuociO8e8VJzEaZ1bLhhb8ttipzIzn7wgrQ3PUUjHCar8eCd06jg)\n\n\u003e [!NOTE]\n\u003e Previous WASM version available at https://github.com/slainless/digides-ogimage.\n\n## Known issue\n\nThe worker will always (weirdly) throw error but not providing any meaningful error trace.\n\n```\n[wrangler:inf] GET / 200 OK (44ms)\n✘ [ERROR] Uncaught (in promise) Response\n\n\n✘ [ERROR] Uncaught (async) Error: #\u003cResponse\u003e\n\n```\n\nBut it's pretty much safe to ignore since it's uncaught and not affecting the service at all.\nI don't know why in hell would `WebAssembly.Instance` instantiation throws error.\n\n## Difference with previous repository\n\nThis project is built on top of WASIP1 instead of javascript WASM. \nThe flow of data is greatly simplified, reading data from `stdin` and write to `stdout`. \nSince there is no necessity for memory reading yet, the WASI code is pretty simple.\n\nSince previous version relies a lot on faulty implementations based on syscall/js, \nit's failed to create a proper stream from JPEG encoder to worker response output.\nIt's not the case for this version since we are working directly on `io.Writer` provided\nby worker's `TransformStream`.\n\nRendering bug on previous repo is also fixed by default by changing the OS to WASIP1.\n\nThis project can also be built with `tinygo` easily with no code change, \nbut it's not working properly in production (on worker); It will return broken image.\n\n## Performance\n\nManaged to hit TTFB at average 0.2ms~0.5ms and streamed the response at average ~1s. \nThe biggest bottleneck in this case is the JPEG encoder. \n`IMAGE_QUALITY` env can be used to set encoding output quality and possibly reduce encoding time (?). \n\nAlso, since we are streaming the result of JPEG encoder directly to WASI preopens stdout and worker\nenvironment piped it to the response body, we essentially created a true stream. This allows our service to be\ntruly responsive by returning the first byte early and offsetting the penalty of long encoding time by\nslowing down and syncing the download timing with encoding process.\nThis will also reduce the risk of timeout occuring on open-graph consumer and hopefully will resolve\n\"image preview not showing\" issue on some chat apps, which we think are caused by timeout.\n\n## Future plan\n\nThis repo is production ready, with WASM loaded correctly and service running.\n\nConsidering that [cloudflare WebGPU API is not ready yet](https://developers.cloudflare.com/durable-objects/api/webgpu/) \n(and even then, it's only supported on Durable Objects), the only choice is to render using CPU. Not that I know how to program using \nWebGPU (I wish I have time to learn it), but it's the best option for graphic drawing in Cloudflare Worker.\n\nI'm thinking of incorporating libvips either via C binding (if at all possible) or by running wasm runtime on Go to load another wasm, \ndon't know if this is even possible.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fslainless%2Fdigides-ogimaker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fslainless%2Fdigides-ogimaker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fslainless%2Fdigides-ogimaker/lists"}