{"id":19508383,"url":"https://github.com/red-scorp/image_resizer","last_synced_at":"2026-05-14T17:41:00.976Z","repository":{"id":232259785,"uuid":"783570640","full_name":"red-scorp/image_resizer","owner":"red-scorp","description":"Image resizer is a python script for large datasets with multiprocessing support ","archived":false,"fork":false,"pushed_at":"2024-08-13T11:18:22.000Z","size":16,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-08T11:37:49.434Z","etag":null,"topics":["dataset","graphics","image","image-dataset","image-processing","python3","resize","stable-diffusion"],"latest_commit_sha":null,"homepage":"","language":"Python","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/red-scorp.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":"2024-04-08T06:43:25.000Z","updated_at":"2024-08-13T11:18:25.000Z","dependencies_parsed_at":"2025-01-08T11:31:43.188Z","dependency_job_id":"f6fd0322-4a72-4cf7-9fc4-45bc898dda84","html_url":"https://github.com/red-scorp/image_resizer","commit_stats":null,"previous_names":["red-scorp/image_resizer"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/red-scorp%2Fimage_resizer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/red-scorp%2Fimage_resizer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/red-scorp%2Fimage_resizer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/red-scorp%2Fimage_resizer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/red-scorp","download_url":"https://codeload.github.com/red-scorp/image_resizer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240761082,"owners_count":19853254,"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":["dataset","graphics","image","image-dataset","image-processing","python3","resize","stable-diffusion"],"created_at":"2024-11-10T23:06:20.604Z","updated_at":"2026-05-14T17:40:55.957Z","avatar_url":"https://github.com/red-scorp.png","language":"Python","funding_links":["http://paypal.me/redscorp","http://ko-fi.com/redscorp"],"categories":[],"sub_categories":[],"readme":"# image_resizer\n\nThis python script is meant to be user to resize large image datasets to use them in machine learning models. It uses the PIL library to resize the images and the multiprocessing library to speed up the process.\n\n## Usage\n\nThe main usage of the script is to resize bunch of images from input directory tree to output directory tree. The script will keep the same directory structure in the output directory as in the input directory.\n\nFor example, this command will resize all images to fit into `1024`x`1024` px from the input directory and save them in the output directory with the same directory structure:\n\n```bash\npython3 image_resizer.py -i /path/to/input_dir -o /path/to/output_dir -s 1024\n```\n\nThe script will create the output directory if it does not exist.\n\n## Options\n\nFull usage information can be found by running the script with the `-h` flag:\n\n```bash\npython3 image_resizer.py -h\n```\n\nThis will print the following help message:\n\n```\nusage: image_resizer.py [-h] -i INPUT -o OUTPUT [-s SIZE] [-r RESIZE_MODE] [-f FORMAT] [-n NUM_PROCESSES] [-m] [-M]\n                        [-R RENAME] [-v]\n\nResize images in a directory tree.\n\noptions:\n  -h, --help            show this help message and exit\n  -i INPUT, --input INPUT\n                        Input directory containing images.\n  -o OUTPUT, --output OUTPUT\n                        Output directory to store resized images.\n  -s SIZE, --size SIZE  Size to resize the images. Default is 512.\n  -r RESIZE_MODE, --resize-mode RESIZE_MODE\n                        Resize mode for images (none, thumbnail, cover or crop). Default is thumbnail.\n  -f FORMAT, --format FORMAT\n                        Output format for resized images (same, png, jpg, gif, tiff, bmp and webp). Default is same.       \n  -n NUM_PROCESSES, --num-processes NUM_PROCESSES\n                        Number of processes to use for resizing. Default is number of available CPU cores.\n  -m, --add-mirror      Add a mirrored version of each image.\n  -M, --mirror-only     Produce only a mirrored version of each image.\n  -R RENAME, --rename RENAME\n                        Rename the resized images using a pattern (none, counter, 0-counter, md5). Default is none.        \n  -v, --verbose         Verbose output.\n```\n\nFollowing options are available to customize the resizing process:\n\n| Option | Description |\n| --- | --- |\n| `-h`, `--help` | **Show this help message and exit.** The script will print the help message and exit. |\n| `-i`, `--input` | **Input directory containing images.** The script finds all JPEG and PNG images for processing. |\n| `-o`, `--output` | **Output directory to store resized images.** The script will keep the same directory structure in the output directory as in the input directory. |\n| `-s`, `--size` | **Size to resize the images. Default is `512`.** The default value is chosen to be use with stable diffusion 1.5. For stable diffusion XL use size of `1024`. |\n| `-r`, `--resize-mode` | **Resize mode for images (`none`, `thumbnail`, `cover` or `crop`). Default is `thumbnail`.** The resize modes are covering different use cases. \u003cul\u003e\u003cli\u003e`none` will ignore any `size` values and leave the image as it is.\u003c/li\u003e\u003cli\u003e `thumbnail` wants to resize original image to fit in `size`x`size` square, this means the smaller side of the output image will be smaller then `size`. \u003c/li\u003e\u003cli\u003e `cover` wants to cover `size`x`size` square, the bigger side of the image will be bigger then the `size`. \u003c/li\u003e\u003cli\u003e `crop` will act as `cover` and crop the output image to `size`x`size` square. \u003c/li\u003e\u003c/ul\u003e |\n| `-f`, `--format` | **Output format for resized images (`same`, `png`, `jpg`, `gif`, `tiff`, `bmp` and `webp`). Default is `same`.** The script can additionally produce output in specific image format. \u003cul\u003e\u003cli\u003e `same` will save output files in original image format. \u003c/li\u003e\u003cli\u003e `png` will convert images to PNG format. \u003c/li\u003e\u003cli\u003e `jpg` will generate JPEG output files. \u003c/li\u003e\u003cli\u003e `gif` will generate GIF output files. \u003c/li\u003e\u003cli\u003e `tiff` will generate TIFF output files. \u003c/li\u003e\u003cli\u003e `bmp` will generate BMP output files. \u003c/li\u003e\u003cli\u003e `webp` will generate WEBP output files. \u003c/li\u003e\u003c/ul\u003e |\n| `-n`, `--num-processes` | **Number of processes to use for resizing. Default is number of available CPU cores.** The script will use multiprocessing to speed up the resizing process. |\n| `-m`, `--add-mirror` | **Add a mirrored version of each image.** The script will add a mirrored version of each image to the output directory. The mirrored file will be saved with following name format `\u003coriginal_image\u003e_mirror.\u003cext\u003e`. The idea of adding mirrored versions of the images to your training dataset is to remove biases from your input images. |\n| `-M`, `--mirror-only` | **Produce only a mirrored version of each image.** The script will produce only a mirrored version of each image to the output directory. This option can be used to add mirrored images to existing output directory tree. |\n| `-R`, `--rename` | **Rename the resized images using a pattern (`none`, `counter`, `0-counter`, `md5`). Default is `none`.** The script can rename the resized images using a pattern. \u003cul\u003e\u003cli\u003e `none` will keep the original file names. \u003c/li\u003e\u003cli\u003e `counter` will rename the files using a counter. \u003c/li\u003e\u003cli\u003e `0-counter` will rename the files using a counter with leading zeros. \u003c/li\u003e\u003cli\u003e `md5` will rename the files using MD5 hash of the resulting file. \u003c/li\u003e\u003c/ul\u003e |\n| `-v`, `--verbose` | **Verbose output.** The script will print more information about the processing. Adding more `-v` options will increase information you will see during directory resizing. |\n\n## How You Can Contribute\n\nWe welcome your contributions to the ag-panel project! Whether it's code, resources, or financial support, your help is invaluable. Feel free to reach out directly via email at andriy.golovnya@gmail.com or through my [GitHub profile](https://github.com/red-scorp).\n\nIf you'd like to make a financial contribution to support the project's development, you can donate via [PayPal](http://paypal.me/redscorp) or [Ko-Fi](http://ko-fi.com/redscorp). Your generosity is greatly appreciated.\n\nThank you in advance for your support, and let's make the ag-panel project even better together!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fred-scorp%2Fimage_resizer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fred-scorp%2Fimage_resizer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fred-scorp%2Fimage_resizer/lists"}