Split-Image는 명령 줄에서 사용하여 이미지를 타일로 분할 할 수있는 파이썬 패키지입니다.
pip install split-image
명령 줄에서 :
split-image [-h] [-s] image_path rows cols
일반 모듈 가져 오기 :
from split_image import split_image
split_image ( image_path , rows , cols , should_square , should_cleanup , [ output_dir ])
# e.g. split_image("bridge.jpg", 2, 2, True, False)
split-image cat.png 2 2
이것은 cat.png
이미지를 4 타일 ( 2
행 및 2
열)으로 나눕니다.
split-image bridge.png 3 4 -s
이것은 bridge.png
이미지를 12 개의 타일 ( 3
행 및 4
열)으로 나눕니다. -square
Arguments는 이미지를 분할하기 전에 정사각형으로 선정합니다. 정사각형을 채우는 데 사용되는 배경색은 이미지에서 자동으로 결정됩니다.
split-image cat.jpg 2 2 -r
유사하게 명명 된 이미지 타일을 하나의 이미지로 병합하려고 시도합니다. 따라서 현재 디렉토리에 이러한 이미지가있는 경우 다음과 같습니다.
cat_0.jpg
cat_1.jpg
cat_2.jpg
cat_3.jpg
파일 이름에 따라 병합됩니다.
split-image image_dir 4 2
image_dir
폴더에 포함 된 모든 이미지를 분할합니다.
split-image test.jpg 4 2 --cleanup
프로세스 후 원본 이미지를 삭제합니다.
split-image test.jpg 4 2 --load-large-images
큰 이미지 (178,956,970 픽셀 이상)로 작업 할 때 오류가 발생할 수 있습니다. 이 깃발을 전달하여 이것을 무시하십시오.
split-image test.jpg 2 2 --output-dir <dir-name>
이미지 타일의 출력 디렉토리를 설정합니다 (예 : 'Outp/Images'). 기본값은 현재 작업 디렉토리로 나타납니다.
split-image test.jpg 3 4 --quiet
실행할 때 모든 로그 메시지 (오류 및 경고 제외)를 억제합니다.
positional arguments:
image_path The path to the image or directory with images to split.
rows How many rows to split the image into (horizontal split).
cols How many columns to split the image into (vertical split).
optional arguments:
-h, --help Show this help message and exit
-s, --square If the image should be resized into a square before splitting.
-r, --reverse Reverse the splitting process, i.e. merge multiple tiles of an image into one.
--cleanup After splitting or merging, delete the original image/images.
--load-large-images Pass this flag for use with really large images.
--output-dir <dir-name> Set the output directory for image tiles (e.g. 'outp/images').
--quiet Run without printing any messages.
Unsplash에 Manja Varolic의 고양이 사진
Unsplash의 Lance Asper의 브리지 사진