{"id":13495532,"url":"https://github.com/hanzhi713/image-collage-maker","last_synced_at":"2025-08-22T07:31:30.192Z","repository":{"id":40002751,"uuid":"156030970","full_name":"hanzhi713/image-collage-maker","owner":"hanzhi713","description":"A photo mosaic (pixel collage) maker. Use all your friends' profile pictures to approximate your profile picture! 如何用 Python 制作一个炫酷的微信好友图","archived":false,"fork":false,"pushed_at":"2023-06-27T20:40:46.000Z","size":150207,"stargazers_count":158,"open_issues_count":1,"forks_count":13,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-12-11T12:51:33.531Z","etag":null,"topics":["collage","collage-maker","photo-mosaic","photomosaic","photomosaic-generator","wechat-friends"],"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/hanzhi713.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":"2018-11-03T22:57:40.000Z","updated_at":"2024-11-28T06:40:01.000Z","dependencies_parsed_at":"2024-10-31T10:42:07.717Z","dependency_job_id":null,"html_url":"https://github.com/hanzhi713/image-collage-maker","commit_stats":null,"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hanzhi713%2Fimage-collage-maker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hanzhi713%2Fimage-collage-maker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hanzhi713%2Fimage-collage-maker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hanzhi713%2Fimage-collage-maker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hanzhi713","download_url":"https://codeload.github.com/hanzhi713/image-collage-maker/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230568591,"owners_count":18246378,"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":["collage","collage-maker","photo-mosaic","photomosaic","photomosaic-generator","wechat-friends"],"created_at":"2024-07-31T19:01:35.652Z","updated_at":"2024-12-20T10:09:13.222Z","avatar_url":"https://github.com/hanzhi713.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"\u003ctable style=\"border: 0; text-align: center\"\u003e\r\n    \u003ctr\u003e\r\n        \u003ctd\u003eTiles\u003c/td\u003e\r\n        \u003ctd\u003ePhotomosaic (Fair tile usage)\u003c/td\u003e\r\n    \u003c/tr\u003e\r\n    \u003ctr\u003e\r\n        \u003ctd\u003e\u003cimg src=\"examples/unsorted.png\" width=\"480px\"\u003e\u003c/td\u003e\r\n        \u003ctd\u003e\u003cimg src=\"examples/fair-dup-10.png\" width=\"270px\"\u003e\u003c/td\u003e\r\n    \u003c/tr\u003e\r\n    \u003ctr\u003e\r\n        \u003ctd\u003eTiles Sorted by RGB sum\u003c/td\u003e\r\n        \u003ctd\u003ePhotomosaic (Best-fit)\u003c/td\u003e\r\n    \u003c/tr\u003e\r\n    \u003ctr\u003e\r\n        \u003ctd\u003e\u003cimg src=\"examples/sort-bgr.png\" width=\"480px\"\u003e\u003c/td\u003e\r\n        \u003ctd\u003e\u003cimg src=\"examples/best-fit.png\" width=\"270px\"\u003e\u003c/td\u003e\r\n    \u003c/tr\u003e\r\n\u003c/table\u003e\r\n\r\n# Photomosaic Maker\r\n\r\n![gui demo](./examples/gui.png)\r\n\r\n- [Distinguishing Features of this Photomosaic Maker](#distinguishing-features-of-this-photomosaic-maker)\r\n- [Getting Started](#getting-started)\r\n  - [Using the pre-built binary](#using-the-pre-built-binary)\r\n  - [Running Python script directly](#running-python-script-directly)\r\n- [Command line usage](#command-line-usage)\r\n  - [Option 1: Sorting](#option-1-sorting)\r\n  - [Option 2: Make a photomosaic](#option-2-make-a-photomosaic)\r\n    - [Option 2.1: Give a fair chance to each tile](#option-21-give-a-fair-chance-to-each-tile)\r\n    - [Option 2.2: Best fit (unfair tile usage)](#option-22-best-fit-unfair-tile-usage)\r\n    - [Display salient object only](#display-salient-object-only)\r\n    - [Keep transparency](#keep-transparency)\r\n    - [Blending Options](#blending-options)\r\n    - [Dithering](#dithering)\r\n  - [Option 3: Photomosaic Video](#option-3-photomosaic-video)\r\n  - [Performance, multiprocessing and GPU acceleration](#performance-multiprocessing-and-gpu-acceleration)\r\n    - [Time and space complexity](#time-and-space-complexity)\r\n    - [Multiprocessing](#multiprocessing)\r\n    - [GPU acceleration](#gpu-acceleration)\r\n  - [All command line options](#all-command-line-options)\r\n- [Utility Script: download profile pictures of your WeChat friends](#utility-script-download-profile-pictures-of-your-wechat-friends)\r\n  - [Groupchat Members](#groupchat-members)\r\n  - [All available profile pictures](#all-available-profile-pictures)\r\n  - [Notes](#notes)\r\n- [Credits (Names in alphabetical order)](#credits-names-in-alphabetical-order)\r\n\r\n\r\n## Distinguishing Features of this Photomosaic Maker\r\n\r\nA number of photomosaic makers already exist (like [mosaic](https://github.com/codebox/mosaic) and [Photomosaic-generator](https://github.com/uvipen/Photomosaic-generator)), but this photomosaic maker has the following unique features\r\n\r\n- Can trade off between the fairness of the tiles and quality of the constructed photomosaic\r\n  - Can ensure each tile is used exactly N times if desired (N is customizable)\r\n- Supports non square tile size\r\n- Supports photomosaic videos\r\n- Supports maintaining transparency\r\n- Supports dithering\r\n- Supports saliency detection\r\n- Has a graphical user interface\r\n- Optional GPU acceleration\r\n\r\n## Getting Started\r\n\r\nYou can either use our pre-built binaries from [release](https://github.com/hanzhi713/image-collage-maker/releases) or directly run our python script.\r\n\r\n### Using the pre-built binary\r\n\r\n**If you need GPU acceleration or need to make [photomosaic videos](#option-3-photomosaic-video), please refer to the [Command line usage](#command-line-usage)**\r\n\r\nBinaries can be downloaded from [release](https://github.com/hanzhi713/image-collage-maker/releases).\r\n\r\nOn Windows and MacOS, my program may be blocked because it is not signed (signing costs money!). Don't worry as there is no security risk. On MacOS or Linux, after downloading the binary, you may need to add executing permission. Open your terminal, go to the file's directory and type\r\n\r\n```bash\r\nchmod +x ./photomosaic-maker-5.1-macos-x64\r\n```\r\n\r\nThen you can run from terminal as\r\n\r\n```bash\r\n./photomosaic-maker-5.1-macos-x64\r\n```\r\n\r\n### Running Python script directly\r\n\r\nFirst, you need Python \u003e= 3.7 with pip. You can install dependencies by running\r\n\r\n```bash\r\npip install -r requirements.txt\r\n```\r\n\r\nNote: if have problems installing the packages due to missing dependencies, you can use this command (on Linux) to install them one by one. \r\n\r\n```bash\r\ncat requirements.txt | xargs -n 1 pip install\r\n```\r\n\r\nIf you want GPU acceleration, you need to install cupy. Please consult the [cupy documentation](https://docs.cupy.dev/en/stable/install.html).\r\n\r\nThen, you can either use the GUI by running or refer to the commandline usage.\r\n\r\n```bash\r\npython gui.py\r\n```\r\n\r\nIf you see errors like `No module named '_tkinter'`, you may need to install tkinter in your system like this (command will vary depending on the OS)\r\n\r\n```bash\r\nsudo apt-get install python3-tk\r\n```\r\n\r\nFor command line usage and documentation regarding different photmosaic options, please refer to the section below.\r\n\r\n## Command line usage\r\n\r\n\u003e If you do not wish to use the GUI, a command line interface is also available. Make sure that you've installed dependencies in the section above. \r\n\r\n### Option 1: Sorting\r\n\r\n```bash\r\npython make_img.py --path img/zhou --sort bgr_sum --size 50 --out examples/sort-bgr.png\r\n```\r\n\r\n`--size` takes one or two arguments. If only one is specified, it is interpreted as the tile width and tile height will be inferred from the aspect ratios of the tiles provided (this corresponds to the `infer height` option in the GUI). If two are specified, they are interpreted as width and height. \r\n\r\nUse `--ratio w h` to change the aspect ratio, whose default is 16:9. E.g. `--ratio 21 9` specifies the aspect ratio to be 21:9. \r\n\r\n\u003e Note: when the tiles are a bit short to completely fill the grid, white tiles will be added. \r\n\r\nResult:\r\n\r\n\u003cimg src=\"examples/sort-bgr.png\"/\u003e\r\n\r\n### Option 2: Make a photomosaic\r\n\r\nTo make a photomosaic, specify the path to the destination image using `--dest_img`\r\n\r\n#### Option 2.1: Give a fair chance to each tile\r\n\r\nThis fitting option ensures that each tile is used for the same amount of times, but is the most computationally and memory intensive option. \r\n\r\n\u003e a few tiles might be used one more time than others. This may happen when the number of tiles is not an integer multiple of the blocks of the destination image. \r\n\r\n```bash\r\npython make_img.py --path img/zhou --dest_img examples/dest.jpg --size 25 --dup 6 --out examples/fair-dup-10.png\r\n```\r\n\r\n`--dup 6` specifies that each tile needs to be used 6 times (i.e. duplicates the set of tiles 6 times). Increase that number if you don't have enough source tiles or you want a better fitting result. This can be a non integer too. For example, `--dup 0.5` means only 50% of the tiles will be used, and `--dup 2.5` means all tiles on average will be used 2.5 times (half of the tiles will be used 2 times and the other half will be used 3 times). \r\n\r\nTo make sure the computation completes within a reasonable amount of time, it is recommended that you use less than 6000 tiles after duplication. Tile number larger than 6000 will probably takes longer than a minute to compute. Note that this recommended limit does **not** apply for the best fit option (see section below). \r\n\r\n| Original                                    | Fitting Result                                     |\r\n| ------------------------------------------- | -------------------------------------------------- |\r\n| \u003cimg src=\"examples/dest.jpg\" width=\"350px\"\u003e | \u003cimg src=\"examples/fair-dup-10.png\" width=\"350px\"\u003e |\r\n\r\n#### Option 2.2: Best fit (unfair tile usage)\r\n\r\nThis fitting option just selects the best subset of tiles you provided to approximate your destination tiles. Each tile in that subset will be used for an arbitrary number of times.\r\n\r\nAdd `--unfair` flag to enable this option. You can also specify `--max_width` to change the width of the grid. The height will be automatically calculated based on the max_width provided. Generally, a larger grid will give a better result. The default value is 80.\r\n\r\n```bash\r\npython make_img.py --path img/zhou --dest_img examples/dest.jpg --size 25 --unfair --max_width 56 --out examples/best-fit.png\r\n```\r\n\r\n|                  Original                   |                 Fitting Result                  |\r\n| :-----------------------------------------: | :---------------------------------------------: |\r\n| \u003cimg src=\"examples/dest.jpg\" width=\"350px\"\u003e | \u003cimg src=\"examples/best-fit.png\" width=\"350px\"\u003e |\r\n\r\nOptionally, you can specify the `--freq_mul` (frequency multiplier) parameter that trade offs between the fairness of the tiles and quality of the mosaic. \r\n\r\n```bash\r\npython3 make_img.py --path img --out best-fit.png --dest_img img/1.png --size 25 --unfair --freq_mul 1.0\r\n```\r\n\r\nThe larger the `freq_mul`, more tiles will be used to construct the photomosaic, but the quality will deteriorate. The results under different `freq_mul` are shown below. Note that if you need a large `freq_mul`, you will better off by going for the fair tile usage (see section above) instead.\r\n\r\n![](examples/fairness.png)\r\n\r\n#### Display salient object only\r\n\r\nThis option makes photomosaic only for the salient part of the destination image. Rest of the area will be transparent. \r\n\r\nAdd `--salient` flag to enable this option. You can still specify whether each tile is used for the same amount of times with the `--unfair` flag.\r\n\r\nUse `--lower_thresh` to specify the threshold for object detection. The threshold ranges from 0.0 to 1.0; a higher threshold would lead to less object area. The default threshold is 0.5.\r\n\r\n```bash\r\npython make_img.py --path img/zhou --dest_img examples/messi.jpg --size 25 --salient --lower_thresh 0.15 --dup 5 --out examples/messi-fair.png\r\n```\r\n\r\n```bash\r\npython make_img.py --path img/zhou --dest_img examples/messi.jpg --size 25 --salient --lower_thresh 0.15 --unfair --max_width 115 --out examples/messi-unfair.png\r\n```\r\n\r\n| Original                                     | Unfair-Fitting Result                               | Fair-Fitting Result                               |\r\n| -------------------------------------------- | --------------------------------------------------- | ------------------------------------------------- |\r\n| \u003cimg src=\"examples/messi.jpg\" width=\"350px\"\u003e | \u003cimg src=\"examples/messi-unfair.png\" width=\"350px\"\u003e | \u003cimg src=\"examples/messi-fair.png\" width=\"350px\"\u003e |\r\n\r\n#### Keep transparency\r\n\r\nIf your destination image has transparent regions, you can add `--transparent` flag to only put tiles for the non transparent part. In this way, the transparent regions are maintained in the resulting photomosaic. Note that this option is not compatible with `--dithering` and `--salient`. \r\n\r\n| Original                                           | Unfair-Fitting Result (`freq_mul=0.5`)                    | Fair-Fitting Result                                |\r\n| -------------------------------------------------- | --------------------------------------------------------- | -------------------------------------------------- |\r\n| \u003cimg src=\"examples/dest-transp.png\" width=\"350px\"\u003e | \u003cimg src=\"examples/transp-unfair-freq.png\" width=\"350px\"\u003e | \u003cimg src=\"examples/transp-fair.png\" width=\"350px\"\u003e |\r\n\r\n\r\n#### Blending Options\r\n\r\nTo enhance the effect of the photomosaic, you can enable alpha or brightness blending. Use the `--blending` option to select the types of blending and `--blending_level` to change the level of blending. \r\n\r\n```bash\r\n# alpha blending\r\npython make_img.py --path img/zhou --dest_img examples/dest.jpg --size 25 --dup 8 --blending alpha --blending_level 0.25 --out examples/blend-alpha-0.25.png\r\n\r\n# brightness blending\r\npython make_img.py --path img/zhou --dest_img examples/dest.jpg --size 25 --dup 8 --blending brightness --blending_level 0.25 --out examples/blend-brightness-0.25.png\r\n```\r\n\r\n| Fair tile usage, no blending                       | Alpha blending (25%)                                    | Brightness blending (25%)                                    |\r\n| -------------------------------------------------- | ------------------------------------------------------- | ------------------------------------------------------------ |\r\n| \u003cimg src=\"examples/fair-dup-10.png\" width=\"350px\"\u003e | \u003cimg src=\"examples/blend-alpha-0.25.png\" width=\"350px\"\u003e | \u003cimg src=\"examples/blend-brightness-0.25.png\" width=\"350px\"\u003e |\r\n\r\n#### Dithering\r\n\r\n\u003e See https://en.wikipedia.org/wiki/Dither for a detailed explanation of dithering\r\n\r\nDithering can be used to reduce color banding when there exists a color gradient. To enable dithering, add `--dither` flag. My implementation uses [Floyd–Steinberg dithering](https://en.wikipedia.org/wiki/Floyd%E2%80%93Steinberg_dithering). Note that this option is incompatible with `--transparent` and `--salient`. \r\n\r\n```bash\r\npython make_img.py --path img/zhou --dest_img examples/dest2.jpg --size 10 --unfair --max_width 200 --freq_mul 0.0 --dither --out examples/dither.png\r\n```\r\n\r\n| Original image                               | Best fit, no dither                              | Best fit, dither                              |\r\n| -------------------------------------------- | ------------------------------------------------ | --------------------------------------------- |\r\n| \u003cimg src=\"examples/dest2.jpg\" width=\"350px\"\u003e | \u003cimg src=\"examples/dither-no.png\" width=\"350px\"\u003e | \u003cimg src=\"examples/dither.png\" width=\"350px\"\u003e |\r\n\r\nWhile dithering works the best when `freq_mul` is set to zero, it can still work and provide some visual differences when `freq_mul \u003e 0`. \r\n\r\n```bash\r\n# dither when freq_mul is 0.1\r\npython make_img.py --path img/zhou --dest_img examples/dest2.jpg --size 10 --unfair --max_width 200 --freq_mul 0.1 --dither --deterministic --out examples/f-dither.png\r\n```\r\n\r\n| Original image                               | `freq_mul = 0.1`, no dither                        | `freq_mul = 0.1`, dither                        |\r\n| -------------------------------------------- | -------------------------------------------------- | ----------------------------------------------- |\r\n| \u003cimg src=\"examples/dest2.jpg\" width=\"350px\"\u003e | \u003cimg src=\"examples/f-dither-no.png\" width=\"350px\"\u003e | \u003cimg src=\"examples/f-dither.png\" width=\"350px\"\u003e |\r\n\r\nNote that dithering is **not supported** in fair mode, when randomization is enabled or when saliency is enabled. Also, dithering is not recommended to use with `--gpu`, or you may experience slow computation compared to CPU processing. \r\n\r\n### Option 3: Photomosaic Video\r\n\r\n![photomosaic-video](examples/v.gif)\r\n\r\nIt is possible to make a photomosaic video simply by repeating the methods listed in Option 2 to every certain frame (specified by `--skip_frame`) of the video. You can pass the path of the video with `--dest_img` and add the `--video` flag to tell the program it is a video. This is much faster than processing the video manually frame by frame (e.g. pass different `dest_img` each time), because a lot of information is cached and can be reused between frames. Example:\r\n\r\n```bash\r\npython make_img.py --path img/catsdogs --dest_img img/2out.mp4 --size 20 --unfair --max_width 100 --freq_mul 2 --out tests/video/frame.png --gpu --video --skip_frame 2\r\n```\r\n\r\nSince photomosaic version 5.2, the output will be uncompressed individual frames rather than a video. This allows users to use custom video encoding format. \r\n\r\nDo note that some options are not supported, and some options are slower than other. Generally, saliency is not recommended to use on videos due to its long computational time and difficulty to tune. Each frame might need its own threshold. \r\n\r\n| Saliency/Fairness | Fair        | Unfair |\r\n| ----------------- | ----------- | ------ |\r\n| saliency enabled  | Unsupported | Slow   |\r\n| saliency disabled | Very slow   | Fast   |\r\n\r\n### Performance, multiprocessing and GPU acceleration\r\n\r\n#### Time and space complexity\r\n\r\nDifferent photomosaic making options have different computational complexity. The following table shows the time and space complexity of different cases. Here, `n` is the number of tiles (after duplication in fair mode), `m` is the number of pixels in the destination image, and `k` is the number of tiles used in the unfair mode (this is equal to your specified `max_width` multiplied by the aspect ratio of your destination image).  \r\n\r\n| Type of photomosaic  | Time complexity    | Space complexity | GPU acceleration                               |\r\n| -------------------- | ------------------ | ---------------- | ---------------------------------------------- |\r\n| Fair                 | `O(nm + n^3)`      | `O(nm)`          | partial (~10x speed up for the `nm` part only) |\r\n| Unfair, freq_mul \u003e 0 | `O(nm + nk log n)` | `O(m + n)`       | full (~5-10x speed up)                         |\r\n| Unfair, freq_mul = 0 | `O(nm + nk)`       | `O(m + n)`       | full (~5-10x speed up)                         |\r\n\r\nTakeaway 1:\r\n\r\nThe high (cubic) computational complexity of the fair mode means that the computation time grows much faster with respect to the number of tiles. It typically takes 30 seconds for 5000 tiles and 5 minutes for 10000 tiles. For large tile count, unless you need strict fair tile usage, you should go for the unfair mode and set freq_mul appropriately. \r\n\r\nTakeaway 2:\r\n\r\nNotice the role of `m` in the complexity. If you have a high-definition destination image (e.g. 8000x6000) and notice the computation time is long, you can first downsample it so the number of pixels (`m`) will be lower. Do note that over downsampling will reduce the quality of the photomosaic. \r\n\r\n#### Multiprocessing\r\n\r\nThe `--num_process` option specifies the number of processes (cpu cores) to use. This defaults to half of you available logical CPUs. However, this only applies to the reading tiles phase and photomosaic video processing. For photomosaic video, if you have a small number of tiles or a large number of available CPU cores, using multiprocessing may be faster than enabling GPU acceleration. \r\n\r\n#### GPU acceleration\r\n\r\nFor command line, GPU acceleration can be enabled with the `--gpu` flag. For GUI (`gui.py`), it will be automatically enabled if you have `cupy` installed. However, note it can only provide the listed speedup if `nm` **is large**, typically **\u003e= 10^10**. Another way to judge whether GPU acceleration could be useful is observe the `Distance matrix size` message from the log. Typically, `Distance matrix size` **\u003e= 100MB** work great on GPU. \r\n\r\n### All command line options\r\n\r\n```python make_img.py -h``` will give you all the available command line options.\r\n\r\n```\r\n$ python make_img.py --help\r\nusage: make_img.py [-h] [--path PATH] [--recursive] [--num_process NUM_PROCESS] [--out OUT] [--size SIZE [SIZE ...]]\r\n                   [--quiet] [--auto_rotate {-1,0,1}] [--resize_opt {center,stretch,fit}] [--gpu]\r\n                   [--mem_limit MEM_LIMIT] [--tile_info_out TILE_INFO_OUT] [--ratio RATIO RATIO]\r\n                   [--sort {none,bgr_sum,av_hue,av_sat,av_lum,rand}] [--rev_row] [--rev_sort] [--dest_img DEST_IMG] \r\n                   [--colorspace {hsv,hsl,bgr,lab,luv}] [--metric {euclidean,cityblock,chebyshev,cosine}]\r\n                   [--transparent] [--unfair] [--max_width MAX_WIDTH] [--freq_mul FREQ_MUL] [--dither]\r\n                   [--deterministic] [--dup DUP] [--salient] [--lower_thresh LOWER_THRESH]\r\n                   [--blending {alpha,brightness}] [--blending_level BLENDING_LEVEL] [--video]\r\n                   [--skip_frame SKIP_FRAME] [--exp]\r\n\r\noptional arguments:\r\n  -h, --help            show this help message and exit\r\n  --path PATH           Path to the tiles (default: None)\r\n  --recursive           Whether to read the sub-folders for the specified path (default: False)\r\n  --num_process NUM_PROCESS\r\n                        Number of processes to use for parallelizable operations (default: 8)\r\n  --out OUT             The filename of the output collage/photomosaic (default: result.png)\r\n  --size SIZE [SIZE ...]\r\n                        Width and height of each tile in pixels in the resulting collage/photomosaic. If two numbers   \r\n                        are specified, they are treated as width and height. If one number is specified, the number    \r\n                        is treated as the width and the height is inferred from the aspect ratios of the images        \r\n                        provided. (default: (50,))\r\n  --quiet               Do not print progress message to console (default: False)\r\n  --auto_rotate {-1,0,1}\r\n                        Options to auto rotate tiles to best match the specified tile size. 0: do not auto rotate. 1:  \r\n                        attempt to rotate counterclockwise by 90 degrees. -1: attempt to rotate clockwise by 90        \r\n                        degrees (default: 0)\r\n  --resize_opt {center,stretch,fit}\r\n                        How to resize each tile so they have the desired aspect ratio and size, which can be\r\n                        specified fully or partially by --size. Center: crop the largest rectangle from the center.    \r\n                        Stretch: stretch the tile. Fit: pad the tiles with white background (default: center)\r\n  --gpu                 Use GPU acceleration. Requires cupy to be installed and a capable GPU. Note that USUALLY this  \r\n                        is useful when you: 1. have a lot of tiles (typically \u003e 10000), and2. are using the unfair     \r\n                        mode, and3. (for photomosaic videos only) only have few cpu coresAlso note: enabling GPU       \r\n                        acceleration will disable multiprocessing on CPU for videos (default: False)\r\n  --mem_limit MEM_LIMIT\r\n                        The APPROXIMATE memory limit in MB when computing a photomosaic in unfair mode. Applicable     \r\n                        both CPU and GPU computing. If you run into memory issues when using GPU, try reduce this      \r\n                        memory limit (default: 4096)\r\n  --tile_info_out TILE_INFO_OUT\r\n                        Path to save the list of tile filenames for the collage/photomosaic. If empty, it will not be  \r\n                        saved. (default: )\r\n  --ratio RATIO RATIO   Aspect ratio of the output image (default: (16, 9))\r\n  --sort {none,bgr_sum,av_hue,av_sat,av_lum,rand}\r\n                        Sort method to use (default: bgr_sum)\r\n  --rev_row             Whether to use the S-shaped alignment. (default: False)\r\n  --rev_sort            Sort in the reverse direction. (default: False)\r\n  --dest_img DEST_IMG   The path to the destination image that you want to build a photomosaic for (default: )\r\n  --colorspace {hsv,hsl,bgr,lab,luv}\r\n                        The colorspace used to calculate the metric (default: lab)\r\n  --metric {euclidean,cityblock,chebyshev,cosine}\r\n                        Distance metric used when evaluating the distance between two color vectors (default:\r\n                        euclidean)\r\n  --transparent         Enable transparency masking. The transparent regions of the destination image will be\r\n                        maintained in the photomosaicCannot be used together with --salient (default: False)\r\n  --unfair              Whether to allow each tile to be used different amount of times (unfair tile usage).\r\n                        (default: False)\r\n  --max_width MAX_WIDTH\r\n                        Maximum width of the collage. This option is only valid if unfair option is enabled (default:  \r\n                        80)\r\n  --freq_mul FREQ_MUL   Frequency multiplier to balance tile fairless and mosaic quality. Minimum: 0. More weight      \r\n                        will be put on tile fairness when this number increases. (default: 0.0)\r\n  --dither              Whether to enabled dithering. You must also specify --deterministic if enabled. (default:      \r\n                        False)\r\n  --deterministic       Do not randomize the tiles. This option is only valid if unfair option is enabled (default:    \r\n                        False)\r\n  --dup DUP             If a positive integer: duplicate the set of tiles by how many times. Can be a fraction\r\n                        (default: 1)\r\n  --salient             Make photomosaic for salient objects only (default: False)\r\n  --lower_thresh LOWER_THRESH\r\n                        The threshold for saliency detection, between 0.0 (no object area = blank) and 1.0 (maximum    \r\n                        object area = original image) (default: 0.5)\r\n  --blending {alpha,brightness}\r\n                        The types of blending used. alpha: alpha (transparency) blending. Brightness: blending of      \r\n                        brightness (lightness) channel in the HSL colorspace (default: alpha)\r\n  --blending_level BLENDING_LEVEL\r\n                        Level of blending, between 0.0 (no blending) and 1.0 (maximum blending). Default is no\r\n                        blending (default: 0.0)\r\n  --video               Make a photomosaic video from dest_img which is assumed to be a video (default: False)\r\n  --skip_frame SKIP_FRAME\r\n                        Make a photomosaic every this number of frames (default: 1)\r\n  --exp                 Do experiments (for testing only) (default: False)\r\n```\r\n\r\n## Utility Script: download profile pictures of your WeChat friends\r\n\r\nIf you have a WeChat account, an utility script `extract_img.py` is provided to download your friends' profile pictures so you can make a photomosaic using them. To use this script, you need to have itchat-uos installed\r\n\r\n```bash\r\npip install itchat-uos\r\n```\r\n\r\nThen, use `--dir` to specify the directory to store the profile pictures of your WeChat friends. \r\n\r\n```bash\r\npython extract_img.py --dir img\r\n```\r\n\r\n### Groupchat Members\r\n\r\nYou can also download the group members' profiles images from a group chat\r\n\r\n```bash\r\npython extract_img.py --dir img --type groupchat --name \"groupchatname\"\r\n```\r\n\r\nYou can download members' profile pictures from all your groupchats if you omit the `--name` argument\r\n\r\n```bash\r\npython extract_img.py --dir img --type groupchat\r\n```\r\n\r\n### All available profile pictures\r\n\r\nYou can download profile pictures from both your friends and members from all your groupchats by specifying `--type all`. \r\n\r\n```bash\r\npython extract_img.py --dir img --type all\r\n```\r\n\r\n### Notes\r\n\r\n1. Due to unknown issues, sometimes some profile pictures are not available, so they will be blank and unusable. The photomosaic maker will automatically ignore them when loading images. \r\n2. When you download a large amount of profile pictures at once, WeChat may block you from downloading more. This will appear as `timeout downloading pics, retrying.... attempt x` in terminal. When this happens, you can terminate the program and run it again a day after. Already downloaded profile pictures will not be downloaded again. \r\n\r\n## Credits (Names in alphabetical order)\r\n\r\nHanzhi Zhou ([hanzhi713](https://github.com/hanzhi713/)): Main algorithm and GUI implementation\r\n\r\nKaiying Shan ([kaiyingshan](https://github.com/kaiyingshan)): Saliency idea and implementation\r\n\r\nXinyue Lin: Idea for the \"Best-fit\"\r\n\r\nYufeng Chi ([T-K](https://github.com/T-K-233/)) : Initial Idea, crawler\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhanzhi713%2Fimage-collage-maker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhanzhi713%2Fimage-collage-maker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhanzhi713%2Fimage-collage-maker/lists"}