LiYing auto-detects bodies and faces, auto-rotates angles, swaps any background color, crops ID photos to any size, and auto-lays out print sheets.
\LiYing runs fully offline — all image processing is local.
\Workflow
\
Results
\
Note: this project is tuned for ID-photo processing — not for arbitrary photos. Inputs should be conventional single-person portraits.
\Unexpected results on complex images are expected.
\If you’re on Windows and don’t need to read the code, grab the bundle (tested on Windows 7 SP1 & Windows 10). Unzip, drag an image or folder onto run.bat to launch.
\This is a bundled Windows package for Windows 7 SP1 and above.
\Install and configure per the steps below to run LiYing locally.
\Prerequisites
\LiYing depends on AGPicCompress, which needs mozjpeg and pngquant.
\You may need to install pngquant manually — see the pngquant docs and drop it in the right place.
\LiYing looks for pngquant in these locations (configurable):
\so AGPicCompress can find and use it for PNG compression.
\Microsoft Visual C++ Redistributable
\Install the latest VC++ Redistributable. On Windows, minimum is Windows 7 SP1.
\For Windows users, the project ships a helper batch:
\\
cd LiYing\
run.bat ./images/test1.jpg\
\
\
python main.py --help\
Usage: main.py [OPTIONS] IMG_PATH\
\
Image-processing CLI\
\
IMG_PATH: input image path\
\
Options:\
-y, --yolov8-model-path PATH YOLOv8 model path\
-u, --yunet-model-path PATH YuNet model path\
-r, --rmbg-model-path PATH RMBG model path\
-b, --bgr-list BGR_LIST BGR channel values (comma-separated) for compositing\
-s, --save-path PATH output path\
-p, --photo-type TEXT photo type\
--photo-sheet-size [5|6] sheet size (5-inch or 6-inch)\
-c, --compress / --no-compress compress image\
-sc, --save-corrected / --no-save-corrected save the corrected image\
-bg, --change-background / --no-change-background replace background\
-sb, --save-background / --no-save-background save the background-swapped image\
-sr, --sheet-rows INTEGER sheet rows\
-sc, --sheet-cols INTEGER sheet columns\
--rotate / --no-rotate rotate photo 90°\
-rs, --resize / --no-resize resize image\
-srz, --save-resized / --no-save-resized save resized image\
--help show this message and exit.\
\
This build ships standard ID-photo presets in data/data.ini — use them via --photo-type.
\You can also edit the config file to define your own types, format:
\\
[XXX]\
print-size = XXXcm x XXXcm\
electronic-size = XXXpx x XXXpx\
dpi = XXXdpi\
\
The section name [XXX] and electronic-size are required. The section name is your --photo-type value.
\Currently the size key only supports the literal key electronic-size; this will be improved in later builds.