최근에 한 번에 여러 장의 사진을 스캔했습니다. 이제 각각 여러 장의 사진을 포함하는 여러 jpeg가 있습니다.
김프를 사용하여 jpg를 3 개의 작은 파일로 "분할"할 수 있습니까?
내가했던 일은 jpg를 3 번 복사하고 각 사본에서 다른 그림을 자르는 것입니다.
이 작업을 수행하는 더 쉬운 방법이 있어야합니다!
편집 : 할 수있는 플러그인이 있습니까? 주위를 둘러 보았지만 이미지를 동일한 크기로 "잘라내는"플러그인 만 발견했습니다.
ImageMagick . 명령 줄 도구이지만 놀랍도록 강력하고 유연하기 때문에 학습 할 가치가 있습니다. 예를 들면 :
convert -extract 1024x1024+0+0 original.png target.png
어디:
이러한 명령 수십 개를 .cmd 파일에 삽입하여 손쉽게 실행할 수 있습니다.
이러한 명령에 대한 수천 가지 옵션이 있는지 확인하려면 ImageMagick 설명서를 참조하십시오. 매우 강력한 도구이자 오픈 소스입니다!
다음과 같이 할 수 있습니다.
Michael의 Paste as-> New Image가 작동하지만 일반적으로 Copy보다는 Cut을 사용하므로 콘텐츠를 복제하지 않습니다.
가이드 행과 단두대 (종이 커터) 도구를 사용하여 김프에서 이미지를 행-열 방식으로 나눌 수 있습니다. 김프 사용 설명서 에서 :
이미지 그리드 외에도 김프는 더 유연한 유형의 포지셔닝 보조 도구 인 가이드를 제공합니다. 작업하는 동안 이미지에 일시적으로 표시 할 수있는 수평선 또는 수직선입니다.
안내선을 만들려면 마우스 버튼을 누른 상태에서 이미지 창에서 눈금자 중 하나를 클릭하고 안내선을 당깁니다. 그러면 가이드가 포인터를 따라가는 파란색 파선으로 표시됩니다. 안내선을 만드는 즉시 "이동"도구가 활성화되고 마우스 포인터가 이동 아이콘으로 변경됩니다.
Guillotine 명령은 이미지 가이드에 따라 현재 이미지를 분할합니다. 사무실에서 단두대 (종이 절단기)로 문서를 자르는 것과 비슷하게 각 가이드를 따라 이미지를 자르고 조각에서 새로운 이미지를 만듭니다. 이미지 메뉴 표시 줄에서 Image -> Transform 을 통해이 명령에 액세스 할 수 있습니다. -> 단두대 .
나는 잘 작동하는 Divide Scanned Images 플러그인을 사용하고 있습니다.
빠르게 만들려면 다음을 사용할 수 있습니다.
Ctrl + D 이미지를 복제하려면
Shift + C 이미지 자르기
Ctrl + S 저장하다
현재 선택 항목을 JPG (고정 품질)로 저장하기 위해 간단한 Gimp 플러그인을 작성했습니다.
이를 위해서는 각 사진을 수동으로 선택 해야합니다 . 출력 파일 이름이 자동 생성됩니다.
GitHub 에서 가져 오기/수정
Zond의 답변을 바탕으로 스크립트를 만들었습니다. 사용자 입력 매개 변수에 따라 이미지 파일을 타일링합니다. 스크립트는 다음과 같습니다.
# Usage:
#
# sh crop.sh <tileset_image_file> <tileset_image_width> <tileset_image_height> <tile_size_X> <tile_size_y>
#
# Example:
# sh crop.sh tileset01.png 128 192 32 32
#
# - Will generate 24 tiles of 32x32 named tile1.png, tile2.png, ..., tile24.png
#
# Your tileset file. I've tested with a png file.
Origin=$1
# Control variable. Used to name each tile.
counter=0
# Location of the tool that we are using to extract the files. I had to create a shortcut of the tool in the same folder as the script.
program=convert.exe
# The size of the tile (32x32)
tile_size_x=$4
tile_size_y=$5
# Number of rows (horizontal) in the tileset.
rows=$2
let rows/=tile_size_x
# Number of columns (vertical) in the tileset.
columns=$3
let columns/=tile_size_y
# Tile name prefix.
prefix=tile
# Tile name sufix.
sufix=.png
echo Extracting $((rows * $columns)) tiles...
for i in $(seq 0 $((columns - 1))); do
for j in $(seq 0 $((rows - 1))); do
# Calculate next cut offset.
offset_y=$((i * tile_size_y))
offset_x=$((j * tile_size_x))
# Update naming variable.
counter=$((counter + 1))
tile_name=$prefix$counter$sufix
echo $program -extract $tile_size"x"$tile_size"+"$offset_x"+"$offset_y $Origin $tile_name
$program -extract $tile_size_x"x"$tile_size_y"+"$offset_x"+"$offset_y $Origin $tile_name
done
done
echo Done!
이 스크립트는 ImageMagick의 "sh"및 "convert"도구와 함께 작동합니다. Windows cmd가 기본 방식으로 sh를 제공하는지 확실하지 않습니다.이 경우 이 주제 를 살펴보면 sh가 작동합니다. 또한 ImageMagick이 시스템에 설치되어 있어야하며 스크립트가 실행될 폴더에 변환 도구의 바로 가기가 있어야합니다.
Sh가있는 Linux 용 Vitor 스크립트 세 줄만 바꾸면 됐어요.
#!/usr/bin/env sh
# Usage:
# sh crop.sh <tileset_image_file> <tileset_image_width> <tileset_image_height> <tile_size_X> <tile_size_y>
#
# Example:
# sh crop.sh tileset01.png 128 192 32 32
#
# - Will generate 24 tiles of 32x32 named tile1.png, tile2.png, ..., tile24.png
#
# Your tileset file. I've tested with a png file.
Origin=$1
# Control variable. Used to name each tile.
counter=0
# Location of the tool that we are using to extract the files. I had to create a shortcut of the tool in the same folder as the script.
program=convert
# The size of the tile (32x32)
tile_size_x=$4
tile_size_y=$5
# Number of rows (horizontal) in the tileset.
rows=$2
rows=$((rows / $tile_size_x))
# Number of columns (vertical) in the tileset.
columns=$3
columns=$((columns / $tile_size_y))
# Tile name prefix.
prefix=tile
# Tile name sufix.
sufix=.png
echo Extracting $((rows * $columns)) tiles...
for i in $(seq 0 $((columns - 1))); do
for j in $(seq 0 $((rows - 1))); do
# Calculate next cut offset.
offset_y=$((i * tile_size_y))
offset_x=$((j * tile_size_x))
# Update naming variable.
counter=$((counter + 1))
tile_name=$prefix$counter$sufix
echo $program -extract $tile_size"x"$tile_size"+"$offset_x"+"$offset_y $Origin $tile_name
$program -extract $tile_size_x"x"$tile_size_y"+"$offset_x"+"$offset_y $Origin $tile_name
done
done
echo Done!
여기에 또 하나가 있습니다. 단일 이미지를 4 개로 분할합니다. 원본 이미지의 크기에 따라 값을 아래 스크립트에 수동으로 입력해야합니다. ImageMagick 도구 "식별"또는 "파일"도구를 사용하여 원본 이미지의 너비와 높이를 확인합니다.
'지오메트리'가 지정되는 방법을 보려면 '-extract'에 대한 명령 줄 옵션 을 참조하십시오.
#!/bin/bash
ORIGINAL=Integration_Tree.png
NEW_WIDTH=2598 # 1/2 of the original width
NEW_HEIGHT=1905 # 1/2 of the original height
NEW_SIZE="${NEW_WIDTH}x${NEW_HEIGHT}"
POS_IMG0="0+0"
POS_IMG1="${NEW_WIDTH}+0"
POS_IMG2="0+${NEW_HEIGHT}"
POS_IMG3="${NEW_WIDTH}+${NEW_HEIGHT}"
for X in 0 1 2 3; do
VAR="POS_IMG${X}"
NEW_GEOMETRY="${NEW_SIZE}+${!VAR}" # cunning use of bash variable indirection
CMD="convert -extract ${NEW_GEOMETRY} \"${ORIGINAL}\" \"out${X}.png\""
echo $CMD
convert -extract ${NEW_GEOMETRY} "${ORIGINAL}" "out${X}.png"
if [[ $? != 0 ]]; then
echo "Some error occurred" >&2
exit 1
fi
done