LiYing 20240803 v1 — Auto ID-Photo Processor (Open Source)



📚Video Course
🕒Last updated: 08/05/2024
👥Entrepreneurs / Self-media creators / Cross-border e-commerce sellers / Side-hustlers

Study material — included with membership
Unlock Course with Membership
🔓
Get this course for reference study with membership
📦
Join membership — study all 16742 courses & software tools as reference
🔄
Courses keep updating — members study new material as it arrives
Share:

1. About LiYing

\

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.

\

2. Workflow

\

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.

\

3. Usage

\

01. Bundle

\

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.

\

02. Setup & install

\

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):

\
    \
  • PATH (recommended)
  • \
  • LiYing/src
  • \
  • LiYing/src/ext
  • \
\

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\
\

CLI options

\
\
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.\
\

Other config

\

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.

Related Courses

Email