Hi all,
I am currently searching for a possibility to merge several jpegs into one jpeg.
For example: merging four 512x512 jpegs into one 1024x1024 jpeg.
I want to do this in code, since many images are affected.
The merging should be done losslessly, without decompression & compressing again.
I already searched in the internet, this should be possible, since jpeg is block-based.
Sadly I didn't found any code example about this.
Has anyone of you has some idea, where to get such an example?
Kind regards,
Squarefox
Merging JPEGS without recompression
-
- Posts: 1010
- Joined: Mon Oct 24, 2011 10:03 pm
- Location: 0x45 61 72 74 68 2c 20 69 6e 20 74 68 65 20 73 6f 6c 20 73 79 73 74 65 6d
Re: Merging JPEGS without recompression
jpeg implies lossy compression, it's not a good format to use.
use png or tiff or any other more suitable format (ideally something using DXT compression)
use png or tiff or any other more suitable format (ideally something using DXT compression)
"this is not the bottleneck you are looking for"
Re: Merging JPEGS without recompression
I have done jpeg saving without loss.
I used the FreeImage library and upon saving the parameter JPEG_SUBSAMPLING_444.
Probably this does not help you; i only mention it, because i was surprised myself that
is is possible with jpeg.
I used the FreeImage library and upon saving the parameter JPEG_SUBSAMPLING_444.
Probably this does not help you; i only mention it, because i was surprised myself that
is is possible with jpeg.
Re: Merging JPEGS without recompression
Just my two cents ... JPEG-LS and JPEG-2000 formats support lossless compression. Like AReichl mentioned, FreeImage library can save in those formats.
Re: Merging JPEGS without recompression
The JPEG specification enforces that there should be a loss-less method for image compression, so JPEG is fine as long as you use the lossless setting. That aside, take a good look to the IImage objects, so you can learn how to copy data between software images, prior to converting them into hardware textures, or saving them to disk
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
-
- Posts: 1010
- Joined: Mon Oct 24, 2011 10:03 pm
- Location: 0x45 61 72 74 68 2c 20 69 6e 20 74 68 65 20 73 6f 6c 20 73 79 73 74 65 6d
Re: Merging JPEGS without recompression
lossless jpegs are typically larger than an equivalent png, and you can't have alpha.
"this is not the bottleneck you are looking for"
Re: Merging JPEGS without recompression
I think I get the idea. Jpg compression works with those 8x8 blocks so you should be able to merge compressed images without having to do any kind of de-compression/compression. But reading up on it a little - I think that's only for the compression part - the Huffman coding part seems to use all blocks. So I suspect you would have to that decoding/encoding part at least. And also adapt the meta-data (thought that's the more trivial part).
I haven't heard yet of a tool doing that. It would likely only work if both images used the exact same compression. I guess your best chance is to study libjpeg and see if it offers the functions you would need for this.
I haven't heard yet of a tool doing that. It would likely only work if both images used the exact same compression. I guess your best chance is to study libjpeg and see if it offers the functions you would need for this.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm