{"id":26365098,"url":"https://github.com/dangkhoa2016/rails-8-api-image-processing","last_synced_at":"2025-07-27T22:36:21.204Z","repository":{"id":272404290,"uuid":"916417487","full_name":"dangkhoa2016/Rails-8-API-Image-Processing","owner":"dangkhoa2016","description":"Simple Rails v8 API server that process image using JSON Web Tokens (JWT) for authentication and the famous lipvips library","archived":false,"fork":false,"pushed_at":"2025-03-15T08:22:13.000Z","size":617,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-15T09:24:43.043Z","etag":null,"topics":["color","color-conversion","devise","devise-jwt","faraday","jwt-authentication","libvips","rails8"],"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/dangkhoa2016.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":"2025-01-14T03:44:04.000Z","updated_at":"2025-03-15T08:21:16.000Z","dependencies_parsed_at":"2025-01-14T08:30:49.828Z","dependency_job_id":"68c4a010-caaf-4d2e-8066-5755f2136deb","html_url":"https://github.com/dangkhoa2016/Rails-8-API-Image-Processing","commit_stats":null,"previous_names":["dangkhoa2016/image-processing","dangkhoa2016/rails-8-image-processing","dangkhoa2016/rails-8-api-image-processing"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dangkhoa2016%2FRails-8-API-Image-Processing","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dangkhoa2016%2FRails-8-API-Image-Processing/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dangkhoa2016%2FRails-8-API-Image-Processing/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dangkhoa2016%2FRails-8-API-Image-Processing/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dangkhoa2016","download_url":"https://codeload.github.com/dangkhoa2016/Rails-8-API-Image-Processing/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243919756,"owners_count":20368944,"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":["color","color-conversion","devise","devise-jwt","faraday","jwt-authentication","libvips","rails8"],"created_at":"2025-03-16T19:30:13.331Z","updated_at":"2025-03-16T19:30:13.925Z","avatar_url":"https://github.com/dangkhoa2016.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# Rails v8 API Image Processing with JWT Authentication\n\nThis is a simple Rails v8 API server that process image using JSON Web Tokens (JWT) for authentication. The server is built using the famous `lipvips` library and [Rails-8-API-Authentication](https://github.com/dangkhoa2016/Rails-8-API-Authentication).\n\n## Features\n\n- **Process Image:**\n  - Apply any `lipvips` image processing operation to an image.\n\n## Technologies Used\n\n- **ruby-vips**: Ruby extension for the libvips image processing library ([link](https://github.com/libvips/ruby-vips)).\n- **Faraday**: Simple, but flexible HTTP client library, with support for multiple backend ([link](https://github.com/lostisland/faraday)).\n- **Color Conversion**: A ruby gem to perform color conversions ([link](https://github.com/devrieda/color_conversion)).\n- **Rails-8-API-Authentication**: A simple Rails v8 API server with JWT authentication ([link](https://github.com/dangkhoa2016/Rails-8-API-Authentication)).\n\n## Installation\n\n1. Clone the repository:\n    ```bash\n    git clone \u003crepository-url\u003e\n    cd \u003crepository-folder\u003e\n    ```\n\n2. Install dependencies:\n    ```bash\n    bundle install\n    ```\n\n3. Set up the SQLite database:\n    - The application will automatically create a database file (`development.sqlite`) in the project root directory when the server starts. You can configure your database connection settings in the `config/database.yml` file if needed.\n\n4. Create a `.env` file at the root of your project for environment variables:\n    ```env\n    RAILS_LOG_TO_STDOUT=true\n\tRAILS_ENV=development\n\tPORT=4000\n\tRAILS_MAX_THREADS=1\n    ```\n\n## API Endpoints\n\nYou must include the JWT token in the `Authorization` header for all requests. The token is generated when you log in to the server.\n\n### 1. **POST /image**\n- Process an image using `Vips::Image` and return the processed image.\n- **Body**:\n    ```json\n    {\n      \"url\": \"https://example.com/image.jpg\",\n      \"format\": \"png\",\n      \"background\": \"#ff0000\",\n      \"resize\": {\n        \"width\": 300,\n        \"height\": 300,\n      },\n    }\n    ```\n- **Response**:\n    ```image\n    \u003cprocessed_image\u003e\n    ```\n\n### 2. **GET /image**\n- Process an image using `Vips::Image` and return the processed image.\n- **Body**:\n    ```\n    {\n    }\n    ```\n  **Query**:\n    ```\n    \"url=https://example.com/image.jpg\u0026format=png\u0026background=#ff0000\u0026resize[width]=300\u0026resize[height]=300\"\n    ```\n- **Response**:\n    ```image\n    \u003cprocessed_image\u003e\n    ```\n\n## Example Usage\n\n1. Register a user:\n    ```bash\n    curl -X POST http://localhost:4000/users/register -H \"Content-Type: application/json\" -d '{\"email\": \"user@example.com\", \"password\": \"password123\", \"username\": \"user123\"}'\n    ```\n\n2. Log in to get the JWT token:\n    ```bash\n    curl -X POST http://localhost:4000/users/login -H \"Content-Type: application/json\" -d '{\"username\": \"user123\", \"password\": \"password123\"}'\n    ```\n\n3. Process an image:\n    ```bash\n    curl -X GET http://localhost:4000/image?url=https://[....].png\u0026toFormat=jpg\u0026resize%5Bwidth%5D=300' -H \"Authorization: Bearer \u003cjwt_token\u003e\"\n    ```\n\nfor more information, please check the [image.sh](./manual/image.sh) file.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdangkhoa2016%2Frails-8-api-image-processing","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdangkhoa2016%2Frails-8-api-image-processing","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdangkhoa2016%2Frails-8-api-image-processing/lists"}