ImageMagick (Photo-SE tag: imagemagick) is excellent for this, for both slicing the image into strips, as well as re-combining (if you're making a single "matted" triptych image).
Assuming your single image file is named
input.jpg, the following command will create 3 equal width (within +/- 1 pixel) tall narrow slices
slice_1.jpg ... slice_3.jpg from it:
convert input.jpg: -crop 3x1@ +repage +adjoin slice_%d.jpg
See also ImageMagick's Examples: Cropping into roughly Equally Sized Divisions page for copious examples of use of the
There multiple ways to combine images using ImageMagick. For your purposes, probably the easiest is the
montage slice_*.jpg -tile 3x1 -geometry +10+10 triptych.jpg
This lays out the images (assuming they are the JPGs output from the
convert slice command above) into a three-wide tile with a 10x10 px border between and around them. See ImageMagick's Montage Tile Layout Controls page for more examples.
Another method, below, comes from the accepted answer to the Stack Overflow question, How do I make the images equidistant using imagemagick/montage?,
If you are just making a triptych, you may get on better with
convert +append to lay out images in a row with spacers. So, if your images are
convert -background black \
slice_1.jpg xc:black[10x] slice_2.jpg xc:black[10x] slice_3.jpg +append \
-bordercolor black -border 10 triptych.jpg
xc:black are just the two spacers that you can set the width of explicitly. Then the three images with spacers are set in a horizontal row, using
+append. Finally, at the end, I put a border around the whole lot with
A note regarding image quality (JPEG)
The examples above assumed using a JPEG as the source image. Because JPEG is a lossy image format, manipulations such as slicing, combining (especially with very contrast regions such as adding matte borders between triptych images), etc., will likely result in generational quality loss (that is, every file manipulation).
If your source image is a JPEG, one solution would be to first export it with highest quality settings to a lossless format, such as TIFF or PNG. Then all ImageMagick operations using the PNG would remaining lossless.
Alternately, if your source image came from a RAW source, export the RAW to PNG or TIFF first, and avoid the JPEG path entirely, or at least until the very final output export if necessary. In general, I find it useful to think of JPEG as an output-only format, and not use it as an intermediate stage format that will have further transformations done on it. That's not always an option, but I adhere to it when I can.