26

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

Can I, using GIMP , "split" a jpg into 3 smaller files ?

What I used to do is : copy the jpg 3 times, and crop a different picture in each copy.

There must be an easier way to do this !

EDIT : Is there a plugin that can do that ? I've looked around, but only found plugins that "cut" an image into pieces of equal size.

1
  • can you post an example picture structure? What I'm looking for is if the pictures are separated by blank space or butted up nxt to each other... Commented Oct 25, 2010 at 16:31

12 Answers 12

24

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!

3
  • 2
    How is ImageMagick related to Gimp? Commented May 16, 2019 at 4:40
  • This is good, but Milche's answer should be the accepted one: superuser.com/a/1020395/140266
    – Steve HHH
    Commented Mar 2, 2022 at 19:32
  • how can I drive a car? oh yes you can drive a bicycle. wtf, yet another sneaky ambush by a nerdy commandliner fighting his lonely boring war. Commented Jun 11, 2023 at 8:34
21

You can do it like this:

  • Rectangle select an image
  • Edit -> Copy
  • Edit -> Paste as -> New Image
9

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.

3
  • thanks this works well for my film strips. i do a zealous crop first, to make the guides easier quicker to lay
    – austin
    Commented Mar 22, 2019 at 23:18
  • how to save all sliced images at once? Commented Dec 20, 2020 at 16:51
  • 1
    In 2022 with Gimp 2.10.30, the Guillotine command does not appear in the menu under Image > Transform > Guillotine. Instead, I found it moved and renamed as Image > Slice using guides.
    – Steve HHH
    Commented Mar 2, 2022 at 19:30
7

In order to make it quickly you can use:

Ctrl + D to duplicate the Image
Shift + C to crop the images
Ctrl + S to save

6

Michael's Paste as -> New Image works, but I generally use Cut rather than Copy so I don't duplicate content.

0
5

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

UPDATE: https://github.com/FrancoisMalan/DivideScannedImages

0
2

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

Screenshot

Input vs output

1

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

Here is another: Split a single image into four. The values have to be put in manually into the script below, depending on how large your original image is. Use the ImageMagick tool "identify" or the "file" tool to check the original image's width and height.

See command line options for '-extract' to see how a 'geometry' is specified.

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

Vitor script for linux with sh. I only had to change three lines.

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

In GIMP you can add horizontal/vertical guides to the images and then slice it (Filter > Web > Slice...) Adding Guides Slicing Sliced Images

0

You can use irfanview to do this. It has a split image feature in the Options menu that lets you specify the number of columns and rows you would like, the output directory, and the result image types the image is split into. It then creates new files with a suffix that differentiates the files.

For example: File.jpg split 3x2 would give File_1x1.jpg File_1x2.jpg ... File_3x2.jpg

I scan lots of 35mm slides this way as it puts 1/3 the wear on the scanner, and scans in 1/3 the time. 12 slides per tray, 4 images of 3 slides. With a slight drop in image quality, it's also possible to scan 20 slides (5 images of 4 slides each) at once by scanning directly on the bed like 8x10 images are scanned. But dealing with 20 loose slides, keeping the bed clean and mitigating dust becomes an issue.

After a film roll has been scanned and split, I use the batch rename feature to rename the files so they have the same numbering as on the slides. That way it's easy to go back and rescan a slide if there's dust in the image.

It also has a handy feature for generating index image sheets from the thumbnail viewer which I print to go with the slides or negs, so it's easy to find the "analog" image from the digital image (and vice versa).

One note of warning. Irfan view remembers entered fields between runs. So, for example, if you enter in the directory to store the split files on one run/roll, and then forget to change it on another run, then you'll overwrite files. This isn't a problem if you use roll descriptive file names like: "John Doe 1957-08 Wedding Roll 1.tif"

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .