Merging JPEGS without recompression

Post your questions, suggestions and experiences regarding to Image manipulation, 3d modeling and level editing for the Irrlicht engine here.

Merging JPEGS without recompression

Postby Squarefox » Wed Apr 26, 2017 2:48 pm

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
User avatar
Squarefox
Competition winner
 
Posts: 105
Joined: Tue Aug 19, 2008 6:46 pm
Location: Delta quadrant, Borg nexus 0001

Re: Merging JPEGS without recompression

Postby devsh » Wed Apr 26, 2017 5:59 pm

use pngs
User avatar
devsh
Competition winner
 
Posts: 1824
Joined: Tue Dec 09, 2008 6:00 pm
Location: UK

Re: Merging JPEGS without recompression

Postby Cube_ » Wed Apr 26, 2017 8:38 pm

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)
"this is not the bottleneck you are looking for"
User avatar
Cube_
 
Posts: 1011
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

Postby AReichl » Thu Apr 27, 2017 7:56 am

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.
AReichl
 
Posts: 235
Joined: Wed Jul 13, 2011 2:34 pm

Re: Merging JPEGS without recompression

Postby MartinVee » Thu Apr 27, 2017 12:28 pm

Just my two cents ... JPEG-LS and JPEG-2000 formats support lossless compression. Like AReichl mentioned, FreeImage library can save in those formats.
User avatar
MartinVee
 
Posts: 122
Joined: Tue Aug 02, 2016 3:38 pm
Location: Québec, Canada

Re: Merging JPEGS without recompression

Postby Mel » Sat Apr 29, 2017 10:43 am

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
User avatar
Mel
Competition winner
 
Posts: 2243
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Re: Merging JPEGS without recompression

Postby Cube_ » Sat Apr 29, 2017 10:45 am

lossless jpegs are typically larger than an equivalent png, and you can't have alpha.
"this is not the bottleneck you are looking for"
User avatar
Cube_
 
Posts: 1011
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

Postby CuteAlien » Sat Apr 29, 2017 2:21 pm

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.
IRC: #irrlicht on irc.freenode.net
Code snippets, patches&stuff: http://www.michaelzeilfelder.de/irrlicht.htm
Free racer created with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
User avatar
CuteAlien
Admin
 
Posts: 8438
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany


Return to Everything 2d/3d Graphics

Who is online

Users browsing this forum: No registered users and 1 guest

cron