How to merge JPG Files? - Graphics

This is a discussion on How to merge JPG Files? - Graphics ; Hi All, is it possible, to merge several JPG files into 1 big one? The graphic software I am currently using is InfranView. Marcus...

+ Reply to Thread
Results 1 to 3 of 3

How to merge JPG Files?

  1. Default How to merge JPG Files?

    Hi All,

    is it possible, to merge several JPG files into 1 big one?

    The graphic software I am currently using is InfranView.


  2. Default Re: How to merge JPG Files?

    Marcus O. M. Grabe <> wrote:
    > Hi All,

    > is it possible, to merge several JPG files into 1 big one?

    > The graphic software I am currently using is InfranView.

    Sure. A friend of mine working at University of California, Davis,
    recently took a collection of 10,000 x 10,000 JPEG photos and
    combined them together into one huge 30,000 x 30,000 image, and then
    split it back up into a collection of 256 x 256 images, for use with the
    Google Maps API.

    He now has a (non-public, sadly) zoomable Google Map interface into a
    large chunk of night sky. Quite awesome.

    I believe he was simply using some shell-based tools on Linux
    (like NetPBM-and-CJPEG/DJPEG tools and/or ImageMagick, to do all of this
    cutting/pasting/cropping automatically in a large batch).

    NetPBM's "pnmcat" seems like a sensible tool:

    pnmcat - concatenate portable anymaps

    Reads portable anymaps as input. Concatenates them either left to
    right or top to bottom, and produces a portable anymap as output.

    So, for example,

    # Convert a pair of JPEGs into PPM bitmaps, for use by "ppmcat"
    djpeg photo1.jpg > photo1.ppm
    djpeg photo2.jpg > photo2.ppm

    # Concatenate the photos together, into a new PPM bitmap
    pnmcat -leftright photo1.ppm photo2.ppm > bigphoto.ppm

    # Concvert the new PPM back into a JPEG
    cjpeg bigphoto.ppm > bigphoto.jpg

    # Clean up!
    # Use "del" instead of "rm" if using MSDOS (aka MS Windows)
    rm photo1.ppm photo2.ppm bigphoto.ppm

    That could be done as a shell script under Unix-like systems
    (Linux, BSD, Mac OS X, MS Windows with Cgywin) or as an MSDOS batch file
    under systems using MSDOS (e.g., WindowsXP).

    I'm almost positive NetPBM is available for Windows, and would be amazed
    if it wasn't available for Mac OS X, at least as a Fink package.

    Good luck!

    -bill! Tux Paint 2006 wall calendar, CDROM, bumper sticker & apparel

  3. Default Re: How to merge JPG Files?

    Marcus O. M. Grabe <> wrote:
    > Hi All,
    > is it possible, to merge several JPG files into 1 big one?

    And now for the GUI answer, in case you're a command-line-o-phobe...
    (In which case, I feel bad for you :^) Command-lines are powerful!
    Especially if you're using a Unix-like environment like Linux, BSD,
    Mac OS X or Cygwin-on-Windows... and not that horrid MSDOS crap!)

    You can use The GIMP, which is Open Source (free) and available for Linux,
    Windows, Mac OS X and other platforms.

    Here are some instructions on combining two images using The GIMP:

    1. Open the first image:
    * File->Open..., find and open the file

    2. Open the second image. (Like above)

    [... repeate if necessary for additional images ...]

    3. Determine the total size you need your new image to be,
    depending on how you want them laid out. One next to the other?
    One on top of another? A 2x2 grid of four images? Et cetera...

    I have an image that's 77x41 and another that's 92x40.

    If I want them next to each other, the new image would need to be
    (77 + 92) x max(40,41), or 169x41.

    If I want them on top of each other, it would need to be
    max(77,92) x (40 + 41), or 92x81. Let's do this one...

    * The image's window titles show their current canvas size.
    (e.g., "blue.bmp-2.0 (RGB, 1 layer) 94x40" <-- right there!)

    4. Resize one of the images to this new size.

    * Within one of the image windows, choose Image->Canvas Size...

    I've decided the 77x41 one will be the 'top' image.
    (I want above the other one, the 92x40 image.)
    So I click that window's "Image" menu and select "Canvas Size..."

    * In the pop-up window that appears, notice the "Canvas Size" section,
    where "Width" and "Height" text fields are available.

    * Next to the Width/Height fields is a little 'chain link'.
    Click this to _unlink_ the width and height.

    (Otherwise, any changes to one will affect the other,
    since The Gimp will be trying to keep the next size at the
    same aspect ratio.)

    * Enter the new Width and Height. (e.g., W=92 and H=81)

    * Adjust the position of this image, in relation to the new size it
    will become.

    Since I'm using the 77x41 image as the basis of my new one,
    I might want to center it horizontally above the second image I'll
    soon be placing below it. Change the "X" and "Y" fields in this
    window, or click and drag the image within the new canvas size.

    The "Center" button can be useful, too. In this example, I click
    it and X and Y become 7 and 20. That's fine for X, but I'll need
    to change Y back to 0.

    * Click "Resize". The image will resize.

    5. Flatting the image.

    The new image _may_ have an alpha channel, in which case the
    'background' will appear as a checkerboard, and the original contents
    will have a black-and-yellow dashed outline.

    We'll deal with this later, but it's easier to deal with it now...

    * _If_ your two (or more) images will have any gaps, you'll need to
    first pick a background color. (If not, the background color won't
    matter, since you'll have covered it all up with your various images.)

    My top image is only 77 pixels wide, while my bottom one is 92 wide.
    This means, since I'm centering my top image, I'll have 6-7 pixels
    of 'gap' on either side. I'll assume you'll want a solid color here!

    + In The GIMP's toolbox, you should see a pair of colored boxes
    (if you hover the mouse over if, you'll see it's called the
    "Foreground & Background colors")

    + Click the background color (the lower right box, which by default
    starts out as white). Notice it becomes 'depressed', meaning it's

    + Click the background color _again_. A "Choose Background Color"
    dialog will appear.

    + Select the color you want for your new image's background.
    Press "OK" to close the dialog. Notice the background color in the
    GIMP Toolbox has changed.

    * In the image's window's "Image" menu, choose "Flatten Image."
    The checkerboard 'transparency' background should turn solid
    (your chosen background color).

    5. Copy the second image.

    * In the second image's "Select" menu, choose "All".
    The entire image will be selected.

    * In that image's "Edit" menu, choose "Copy".
    The entire image will be in the clipboard.

    6. Paste the second image into the first.

    * In the first image's "Edit" menu, choose "Paste."

    * The second image should appear (in the center, usually) of the
    newly-resized-and-flatted first image, with an animated black/white
    dashed outline.

    * The "Select Rectangular Regions" (rectangular selection tool) in
    the GIMP Toolbox should be chosen. If not, choose it. Makes things
    easier. ;^)

    * When you position the mouse over the second image (within those
    animated dashes), it should change to an arrow with a little "+"-shaped
    set of arrows next to it. (Similar to the "Move" tool's icon in the

    * Click and drag the second image to where you want it.
    (The image window's Status bar at the bottom should show:
    "Move: #, #", which will help you position it, relative to it's
    current position.)

    Almost done!

    7. 'Anchor' the second image into the first's background layer.

    The GIMP is a layer-based image manipulation tool (like most
    professional commercial cools... Photoshop, Paint Shop Pro, etc.)

    * In the first image's "Layer" menu, select "Anchor Layer".
    This causes the second image that you just pasted-and-position
    (which was 'floating selection') to officially become part of the
    current layer.

    (Since your image was 'flattened,' there was only the one
    layer... that which contained the original image, and a bunch of
    solid color.)

    [... Repeat Steps 5 thru 7 for any additional images ...]

    8. Save your NEW image

    Don't hit [Ctrl]+[S] just yet! That will replace your first image
    with this new, combined image! That's probably not what you want!
    (It's always best to keep your originals, so you can redo or change
    things later! Hard drives are cheap ;^) )

    * In the first image (the now larger-and-combined picture)
    choose "Save As..." from the "File" menu.

    (Note: _Not_ the "File" menu in The GIMP's toolbox! It wouldn't
    know which image you were talking about!)

    * Save your new picture.

    Whew! It's a lot of manual work, but for one-offs, this is fine.

    See where having a shell script or batch file would help?
    If it was written well (dynamic, accepting command-line arguments),
    you could just throw a directory of images at it to get one big one :^)

    For example: birthday_photos/*.jpg birthday_collage.jpg

    or something. :^)

    -bill! Tux Paint 2006 wall calendar, CDROM, bumper sticker & apparel

+ Reply to Thread

Similar Threads

  1. Merge files using awk based on a common value in the files?
    By Application Development in forum awk
    Replies: 0
    Last Post: 04-09-2007, 01:53 PM
  2. Merge two XML files
    By Application Development in forum XML SOAP
    Replies: 2
    Last Post: 11-21-2006, 09:41 AM
  3. merge two files in awk
    By Application Development in forum awk
    Replies: 11
    Last Post: 10-29-2006, 06:36 PM
  4. How to merge two pdf files using or c#
    By Application Development in forum Adobe Acrobat
    Replies: 2
    Last Post: 09-26-2006, 03:30 PM
  5. Merge XML files
    By Application Development in forum XML SOAP
    Replies: 4
    Last Post: 06-13-2005, 08:21 PM