Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question
    
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... –  KronoS Oct 25 '10 at 16:31

7 Answers 7

up vote 17 down vote accepted

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!

share|improve this answer

You can do it like this:

  • Rectangle select an image
  • Edit -> Copy
  • Edit -> Paste as -> New Image
share|improve this answer

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

share|improve this answer

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

share|improve this answer

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

share|improve this answer

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.
share|improve this answer

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
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.