Page 1 of 1

How do I create *.jp2-file with pre-made tiles

Posted: 2014-07-25T03:00:32-07:00
by royeven
Hi. I have six image files I want to make a montage of. Each file is downloaded from the net is 1024x1024 pixels in size. They are named A1, A2, B1, B2, C1, C2, and I want the montage to look like this:

Code: Select all

|--------|--------|
| A1.jpg | A2.jpg |
|        |        |
|--------|--------|
| B1.jpg | B2.jpg |
|        |        |
|--------|--------|
| C1.jpg | C2.jpg |
|        |        |
|--------|--------|
However, my original files are already JPEG-compressed, and I do not have the original files available. I don't want to lose quality when making the montage, so I want the output format to be something lossless. I know that I can use the command

Code: Select all

montage `ls *.jpg | sort` -geometry +0+0 -tile 2x3 -border 0 -frame 0 "montage_geom.png"
to make a lossless png file. But the original jpeg's are a total of 632kB and the resulting png-file is 6MB, or 10 times as big.

I have heard that jpeg2000 are made from tiles, where each tile is compressed individually. Is there a way to stitch these six files together into one, while still retaining all the information in the originals (i.e. not re-encode the information) and keeping the file size at about 650kB?

Re: How do I create *.jp2-file with pre-made tiles

Posted: 2014-07-25T07:53:05-07:00
by snibgo
ImageMagick doesn't have a way to do that. IM works by decompressing all the pixels, doing any required work, and re-compressing.

Re: How do I create *.jp2-file with pre-made tiles

Posted: 2014-07-28T07:47:10-07:00
by royeven
I was afraid of that. After some research I found a different way to do it:
Jpegtran is a program that stitches together two jpegs in a way that they claim is lossless, and from my investigations seems to be.
http://jpegclub.org/jpegtran/.