{"id":14955386,"url":"https://github.com/kananinirav/image-optimization","last_synced_at":"2026-01-20T07:03:29.942Z","repository":{"id":132347549,"uuid":"593588009","full_name":"kananinirav/Image-Optimization","owner":"kananinirav","description":"Image Optimization","archived":false,"fork":false,"pushed_at":"2023-01-27T05:23:28.000Z","size":26,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-07T09:42:55.515Z","etag":null,"topics":["image-optimization","rails7","ruby","ruby-on-rails"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kananinirav.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2023-01-26T11:39:23.000Z","updated_at":"2024-07-15T06:55:11.000Z","dependencies_parsed_at":null,"dependency_job_id":"681ce492-8b70-439a-89cd-612fe29783f6","html_url":"https://github.com/kananinirav/Image-Optimization","commit_stats":{"total_commits":9,"total_committers":2,"mean_commits":4.5,"dds":0.4444444444444444,"last_synced_commit":"758006cf84c708ce7c506dd9a49ab19ce3b8b507"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/kananinirav/Image-Optimization","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kananinirav%2FImage-Optimization","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kananinirav%2FImage-Optimization/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kananinirav%2FImage-Optimization/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kananinirav%2FImage-Optimization/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kananinirav","download_url":"https://codeload.github.com/kananinirav/Image-Optimization/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kananinirav%2FImage-Optimization/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28597985,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-20T02:08:49.799Z","status":"ssl_error","status_checked_at":"2026-01-20T02:08:44.148Z","response_time":117,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["image-optimization","rails7","ruby","ruby-on-rails"],"created_at":"2024-09-24T13:11:04.964Z","updated_at":"2026-01-20T07:03:29.927Z","avatar_url":"https://github.com/kananinirav.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Image Optimization API\n\n## Setup\n\nThis project already contains a tiny Rails app, and you can run it like this:\n\n```ssh\nbundle install # Install dependencies\nbundle exec rails server # Run server. please make sure it is bound on 127.0.0.1:3000 by checking log\n```\n\n## Features\n\n- Endpoint resize a passed image into specific size only when it is large\n- Endpoint accept parameters to control the above optimization behavior\n- Receive an image URL, download an image from the URL, and optimize it in the same manner as the above POST endpoint\n\n## Technologies used\n\n- Ruby on Rails (Ruby: 3.0.3, Rails: 7.0.4)\n- [mini_magick](https://github.com/minimagick/minimagick) For Image Optimization\n\n## Specification\n\nFor more details, see the following sections.\n\n### 1. Endpoint resize a passed image into specific size only when it is large\n\n- endpoint to resize an image into specific size.\n- A responded image should have less than or equal to 200px of width and height\n- The resizing process should keep an image's aspect ratio, and it should work as \"fit\", not \"fill\"\n  - See: [What is the difference between fit and fill?](https://www.bannerbear.com/help/articles/26-difference-between-fit-and-fill/)\n- The endpoint should resize an image only when an image's data size is more than 1MiB\n  - If an image is larger than the threshold, return a resized image in WebP format\n  - If an image is smaller than or equal to the threshold, return it without any modification\n\nAfter implementing this, the behavior should look like this:\n\n```ssh\ncurl -F image=@path/to/large-image.jpg 'http://localhost:3000/optimizations' \u003e response1.webp\ncurl -F image=@path/to/small-image.jpg 'http://localhost:3000/optimizations' \u003e response2.jpg\n```\n\nThen, `response1.webp` should be a resized WebP image, and `response2.jpg` should be the same as `small-image.jpg`.\n\n### 2. Endpoint accept parameters to control the above optimization behavior\n\nModifying the above endpoint to accept parameters to control the optimization behavior.\n\nFor this, we need to support 3 parameters: `width`, `height`, and `threshold`\n\n- `width`: Specify maximum image width when resizing an image\n  - Default value: 200px\n  - Minimum value: 50px\n  - Maximum value: 2000px\n- `height`: Specify maximum image height when resizing an image\n  - Default value: 200px\n  - Minimum value: 50px\n  - Maximum value: 2000px\n- `threshold`: Specify a threshold data size to be used to decide whether we should resize an image or not\n  - Default value: 1MiB\n  - Minimum value: 100KiB\n  - Maximum value: 100MiB\n\nAfter implementing this, a client can control the image optimization behavior like:\n\n``` curl -F image=@path/to/image.jpg 'http://localhost:3000/optimizations?width=100\u0026height=150\u0026threshold=204800' \u003e response.webp ```\n\nThis means that the `image.jpg` will be resized to fit to 100px of width and 150px of height only when the image's data size is more than 200KiB.\n\n### TODO: 3. Receive an image URL, download an image from the URL, and optimize it\n\nGET endpoint that works the same as the above endpoint, but takes an image URL instead of an image binary data.\n\nThe endpoint should support the same parameters as the above endpoint except for the `image` parameter.\n\nThis means that we should be able to see an image with the following URL on a browser:\n\n\u003chttp://localhost:3000/optimizations?url=https%3A%2F%2Fexample.com%2Ftest.jpg%26width%3D100%26height%3D150%26threshold%3D204800\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkananinirav%2Fimage-optimization","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkananinirav%2Fimage-optimization","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkananinirav%2Fimage-optimization/lists"}