{"id":17867147,"url":"https://github.com/caarmen/image-resizer","last_synced_at":"2026-05-03T12:37:48.916Z","repository":{"id":41527850,"uuid":"510066664","full_name":"caarmen/image-resizer","owner":"caarmen","description":"Server to resize an image from a url","archived":false,"fork":false,"pushed_at":"2023-01-16T20:59:05.000Z","size":324,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-07-16T15:00:12.319Z","etag":null,"topics":["docker","fastapi","python"],"latest_commit_sha":null,"homepage":"","language":"Python","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/caarmen.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}},"created_at":"2022-07-03T15:47:45.000Z","updated_at":"2023-11-15T07:25:41.000Z","dependencies_parsed_at":"2023-02-10T06:05:38.151Z","dependency_job_id":null,"html_url":"https://github.com/caarmen/image-resizer","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/caarmen/image-resizer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/caarmen%2Fimage-resizer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/caarmen%2Fimage-resizer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/caarmen%2Fimage-resizer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/caarmen%2Fimage-resizer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/caarmen","download_url":"https://codeload.github.com/caarmen/image-resizer/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/caarmen%2Fimage-resizer/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32569714,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-03T06:36:36.687Z","status":"ssl_error","status_checked_at":"2026-05-03T06:36:09.306Z","response_time":103,"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":["docker","fastapi","python"],"created_at":"2024-10-28T09:44:32.238Z","updated_at":"2026-05-03T12:37:48.899Z","avatar_url":"https://github.com/caarmen.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Image resizer\n\nAn endpoint, using Fast API, that allows resizing an image.\n\n[\u003cimg src=\"https://img.shields.io/badge/license-MIT-lightgrey.svg?maxAge=2592000\"\u003e](https://github.com/caarmen/image-resizer/blob/main/LICENSE.txt)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n[\u003cimg src=\"https://github.com/caarmen/image-resizer/actions/workflows/tests.yml/badge.svg\"\u003e](https://github.com/caarmen/image-resizer/actions?query=workflow%3A%22Run+tests%22++)\n\n## TLDR quickstart\n\nTo run the server in a docker container, and have access to logs and cached data on the host\ninside `/tmp/image-resizer`, use the Docker container hosted on Github packages:\n\n```bash\ndocker pull ghcr.io/caarmen/image-resizer:latest\n\nmkdir -p /tmp/image-resizer/cache\nmkdir -p /tmp/image-resizer/logs\n\ndocker run \\\n    --volume /tmp/image-resizer/cache:/var/cache/image-resizer \\\n    --volume /tmp/image-resizer/logs:/var/log/image-resizer \\\n    --detach \\\n    --publish 8000:8000 \\\n    --env WEB_CONCURRENCY=4 \\\n    --env CACHE_VALIDITY_S=86400 \\\n    --env CACHE_CLEAN_INTERVAL_S=86400 \\\n    ghcr.io/caarmen/image-resizer\n```\n\nThen resize your first image here:\n\nhttp://localhost:8000/resize?image_url=https://github.githubassets.com/images/modules/logos_page/Octocat.png\u0026height=300\u0026width=100\u0026image_format=webp\n\n## Building and running the server from sources\n\n### Running the server locally\n\n```bash\ngit clone https://github.com/caarmen/image-resizer.git\ncd image-resizer\n# optional: command to create virtual environment\npip install -r requirements/prod.txt\npython -m imageresizer.main\n```\n\n### Building the docker image\n\n```bash\ngit clone https://github.com/caarmen/image-resizer.git\ncd image-resizer\ndocker build -t imageresizer .\ndocker run --detach --publish 8000:8000 imageresizer\n```\n\n## Server configuration options\n\nThe following options are valid whether you downloaded the image from Github packages, built the Docker image locally,\nor are running the server directly on your machine.\n\nThe examples specify the image from Github packages `ghcr.io/caarmen/image-resizer`. If you built the image locally,\nuse `imageresizer` instead.\n\n#### Cache and log folders\n\nBy default, the server stores the cache data and logs in the root of the project when run locally, and in\n`/var/cache/image-resizer` and `/var/log/image-resizer` in the Docker container.\n\nYou can change the location of the cache and logs locations with the `CACHE_DIR` and `LOG_DIR` environment variables.\n\nFor example, to store cache and logs in `/tmp/image-resizer/cache` and `/tmp/image-resizer/logs`:\n\nDocker:\n\n```bash\ndocker run --detach --volume /tmp/image-resizer/cache:/var/cache/image-resizer --volume /tmp/image-resizer/logs:/var/log/image-resizer --publish 8000:8000 ghcr.io/caarmen/image-resizer\n```\n\nLocal:\n\n```bash\nCACHE_DIR=/tmp/image-resizer/cache LOG_DIR=/tmp/image-resizer/logs python -m imageresizer.main\n```\n\n#### Worker count\n\nBy default, the server runs with one worker. To change this, specify the number of workers with the\n`WEB_CONCURRENCY` environment variable. For example, to set 4 workers:\n\nDocker:\n\n```bash\ndocker run --detach --env WEB_CONCURRENCY=4 --publish 8000:8000 ghcr.io/caarmen/image-resizer\n```\n\nLocal:\n\n```bash\nWEB_CONCURRENCY=4 python -m imageresizer.main\n```\n\n#### Cache clean schedule\n\nBy default, when purging the cache, the cache is cleaned every 24 hours starting from server launch, and images\nolder than 24 hours are deleted.\n\nTo change this:\n\n* set the `CACHE_VALIDITY_S` environment variable for the duration which images should be cached (in seconds).\n* set the `CACHE_CLEAN_INTERVAL_S` environment variable to specify the interval in seconds between cleaning tasks.\n\nFor example, to purge images older than one hour, every 2 minutes::\n\nDocker:\n\n```bash\ndocker run --detach --env CACHE_VALIDITY_S=3600 --env CACHE_CLEAN_INTERVAL_S=120 --publish 8000:8000 ghcr.io/caarmen/image-resizer\n```\n\nLocal:\n\n```bash\nCACHE_VALIDITY_S=3600 CACHE_CLEAN_INTERVAL_S=120 python -m imageresizer.main\n```\n\n#### Server port\n\nBy default, the server runs on port 8000. To set it to run on a different port, like `8102` for example:\n\nDocker:\n\n```bash\ndocker run --detach --publish 8102:8000 ghcr.io/caarmen/image-resizer\n```\n\nLocal:\n\n```bash\nUVICORN_PORT=8102 python -m imageresizer.main\n```\n\n#### Generated documentation urls\n\nThe following generated documentation urls are exposed. They can be disabled by unsetting their\nenvironment variables.\n\n| Documentation type | Environment variable | Default value |\n|--------------------|----------------------|---------------|\n| OpenAPI json       | `OPENAPI_URL`        | /openapi.json |\n| ReDoc              | `REDOC_URL`          | /redoc        |\n| Swagger UI         | `DOCS_URL`           | /docs         |\n\nExample to disable all documentation urls:\n\nDocker:\n\n```bash\ndocker run --detach --env OPENAPI_URL= --env REDOC_URL= --env DOCS_URL= --publish 8000:8000 ghcr.io/caarmen/image-resizer\n```\n\nLocal:\n\n```bash\nOPENAPI_URL= REDOC_URL= DOCS_URL= python -m imageresizer.main\n```\n\n#### Supported image url schemas\n\nBy default, only the https schema is allowed for image urls. To change this, set the `SUPPORTED_IMAGE_URL_SCHEMAS`\nenvironment variable.\n\nFor example, to support both https and http:\n\nDocker:\n\n```bash\ndocker run --env SUPPORTED_IMAGE_URL_SCHEMAS='[\"https\",\"http\"]' --detach --publish 8000:8000 ghcr.io/caarmen/image-resizer\n```\n\nLocal:\n\n```bash\nSUPPORTED_IMAGE_URL_SCHEMAS='[\"https\",\"http\"]' python -m imageresizer.main\n```\n\n#### Allowed and denied domains\n\nBy default, no restrictions are placed on the domains of image urls. To specifically deny a list of domains, or to\nspecifically only allow a list of domains, set the `DENIED_DOMAINS` or `ALLOWED_DOMAINS` environment variables.\n\nFor example, to ban resizing images on baddomain.com:\n\nDocker:\n\n```bash\ndocker run --env DENIED_DOMAINS='[\"baddomain.com\"]' --detach --publish 8000:8000 ghcr.io/caarmen/image-resizer\n```\n\nLocal:\n\n```bash\nDENIED_DOMAINS='[\"baddomain.com\"]' python -m imageresizer.main\n```\n\n#### Stopping the containers (Docker only)\n\nTo stop the running imageresizer containers:\n\n```bash\nfor container in $(docker ps --filter ancestor=ghcr.io/caarmen/image-resizer --format=\"{{.ID}}\"); do docker stop $container; done\n```\n\nTo stop and delete all the imageresizer containers, a utility script is provided in this repository:\n\n```bash\nbash scripts/docker_remove_containers.bash\n```\n\n## API Usage\n\nBrowse the api docs at http://127.0.0.1:8000/docs\n\nUse the `resize` endpoint.\n\nExample resizing the [GitHub logo](https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png) to 50x100:\n\nhttp://127.0.0.1:8000/resize?image_url=https%3A%2F%2Fgithub.githubassets.com%2Fimages%2Fmodules%2Flogos_page%2FGitHub-Mark.png\u0026width=50\u0026height=100\n\n## Generated API documentation\n\nYou can browse the documentation at the following links:\n\n* Running on the server:\n    - Redoc: http://localhost:8000/redoc\n    - Swagger: http://localhost:8000/docs\n    - Open api doc: http://localhost:8000/openapi.json\n* Static documentation:\n    - Github pages: https://caarmen.github.io/image-resizer/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcaarmen%2Fimage-resizer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcaarmen%2Fimage-resizer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcaarmen%2Fimage-resizer/lists"}