Home » Questions » Computers [ Ask a new question ]

Can GIMP split an image into multiple images?

Can GIMP split an image into multiple images?

I've been scanning a lot of photos recently, more than one at a time. I now have multiple jpegs, each containing multiple photos.

Asked by: Guest | Views: 401
Total answers/comments: 5
Guest [Entry]

"ImageMagick. It's a command-line tool but amazingly powerful and flexible so worth the effort to learn it. For example:

convert -extract 1024x1024+0+0 original.png target.png

Where:

1024x1024 is the width and height of the required crop
+0+0 are x and y offsets into the original image

You can stick dozens of these commands into a .cmd file and run them effortlessly.

Look at the ImageMagick documentation to see there are thousands of options to these commands. A very powerful tool and open source too!"
Guest [Entry]

"You can divide an image in GIMP in a row-column way with guide rows and the guillotine (paper cutter) tool. From GIMP User Manual:

In addition to the image grid, GIMP also gives you a more flexible type of positioning aid: guides. These are horizontal or vertical lines you can temporarily display on an image while you are working on it.
To create a guide, simply click on one of the rulers in the image window and pull out a guide, while holding the mouse button pressed. The guide is then displayed as a blue, dashed line, which follows the pointer. As soon as you create a guide, the “Move” tool is activated and the mouse pointer changes to the Move icon.
The Guillotine command slices up the current image, based on the image's guides. It cuts the image along each guide, similar to slicing documents in an office with a guillotine (paper cutter) and creates new images out of the pieces. You can access this command from the image menubar through Image -> Transform -> Guillotine."
Guest [Entry]

"I've been using the Divide Scanned Images plug-in which works well.

UPDATE: github.com/FrancoisMalan/DivideScannedImages"
Guest [Entry]

"I wrote a simple Gimp plugin to save the current selection as a JPG (fixed quality).

This requires you to manually select each photograph. Output file names are auto-generated.

Get it/modify on GitHub"
Guest [Entry]

"I have made a script based on the answer from Zond. It will tile your image file according with the user input parameters. The script is as follows:

# 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!

The script works with ""sh"" and the ""convert"" tool from ImageMagick. I'm not sure if the windows cmd provides sh in a native way, in this case one can take a look at this topic to get sh working. Furthermore, the ImageMagick must be installed in the system and a shortcut for the convert tool in the same folder in which the script will run.

I've tested only with png images. Hope it helps."