Lossless JPG rotation

Lossless JPG rotation

Post by Hertwi » Sat, 03 Jul 2004 16:32:38


Is this only a marketing term is there really something like "lossless" JPG
(besides JPG2000).

How do I rotate a JPG lossless?
 
 
 

Lossless JPG rotation

Post by Nils Haec » Sat, 03 Jul 2004 17:59:48

JPG decompression and compression consists of various levels, a few are
lossless (so there's no information lost) and few are lossy (so information
gets thrown away).

Lossless rotation refers to a process where you do not again repeat the
lossy steps.

Compression:
- Transform to YCbCr color space (lossless in theory)
- Split in 8x8 blocks, do DCT - discrete cosine transform (lossless in
theory)
- Quantise blocks using Quantisation tables (lossy)
- Huffmann-compress the Quant.blocks (lossless)

Decompression:
- Huffmann-decompress the Quant.blocks (lossless)
- do IDCT - inverse discrete cosine tranfsorm (lossless in theory)
- Transform back to RGB (lossless in theory)

When rotating an image losslessly, this happens:
- Huffmann-decompress the Quant.blocks (lossless)
- Rearrange and flip/mirror Quant.blocks so the image looks rotated.
(lossless)
- Huffmann-compress the Quant.blocks (lossless)

So the rotation of the JPG image does not add additional loss of information
and can thus be repeated endlessly. Contrary, if you would just uncompress,
rotate, and compress the image, it would loose information in each cycle,
since the lossy steps are repeated.

For batch lossless rotation (if the EXIF data contains the orientation of
the image, like for the better modern digital cameras) you can use this
program:
http://www.yqcomputer.com/
(shameless plug, since I wrote it myself)

Kind regards,

Nils Haeck
www.abc-view.com





JPG

 
 
 

Lossless JPG rotation

Post by Danny Heij » Sun, 04 Jul 2004 03:37:07

The Independent JPEG group offers a C library for JPEG operations, download
source code at http://www.yqcomputer.com/

It supports lossless JPEG rotation, I've used it on Windows CE to rotate the
images of a camera.

You could compile it into a dll and expose the functions you need to a
Delphi program.

Danny
---

"Hertwig" < XXXX@XXXXX.COM > schreef in bericht

JPG
 
 
 

Lossless JPG rotation

Post by Lord Cr » Sun, 04 Jul 2004 05:26:16

On Fri, 2 Jul 2004 09:32:38 +0200, "Hertwig" < XXXX@XXXXX.COM >



The (only) lossy step in the compression sequence is the quantizaion
of the DCT blocks. From what i've gathered, you can however simply
rotate the individual blocks (individually and their place in the data
stream), and the output will be rotated. Since you don't do the
quantization step when doing this, you're simply rearranging bits, it
is lossless.

- Asbjn
 
 
 

Lossless JPG rotation

Post by Kiss Mik » Sun, 04 Jul 2004 20:51:05

Hi,
I am also interested in rotating of JPEG images loslessly. I understand the
method You have mentioned here but how do I extract the information stored
in a JPEG file? Where can I find more details about JPEG file's structure
and about the YCbCr color converions, DCT and IDCT?

Thanks!
MikKi
 
 
 

Lossless JPG rotation

Post by Nils Haec » Mon, 05 Jul 2004 03:20:06

> I am also interested in rotating of JPEG images loslessly. I understand
the

You must use a JPG library to do so, or a commandline tool. The commandline
tool "jpegcrop.exe" is very helpful, you can find it here:
http://www.yqcomputer.com/

If you want to implement it without an additional external file, you can
also download the updated JpegEx unit from Daniel Corneanu:
http://www.yqcomputer.com/

I have no demo code available on how to use the functions, perhaps someone
else here has.

Kind regards,

Nils
 
 
 

Lossless JPG rotation

Post by Kiss Mik » Mon, 05 Jul 2004 04:04:21

> If you want to implement it without an additional external file, you can
http://www.yqcomputer.com/
Yes, I would like to do it without external files. JpegEx would be great but
it is not for D3. Do You have any other ideas?

Thank You for Your reply!
MikKi
 
 
 

Lossless JPG rotation

Post by Hertwi » Mon, 05 Jul 2004 08:21:02

Thanks Nils,

The JpegEx looks promissing. I will try this tomorrow!

Hert

----------------------------------------------------


stored
structure
commandline
http://www.yqcomputer.com/
 
 
 

Lossless JPG rotation

Post by Nils Haec » Mon, 05 Jul 2004 14:51:45

D3?? Isn't it time to upgrade then?

If you don't want to upgrade from there, the only suggestion I can give is
to look up the original JPEG to Pascal translation from Jacques Nomssi
Nzali:
http://www.yqcomputer.com/

You'll have to add the lossless transform yourself, which is quite
complicated if you don't know exactly how it works. Example of source code
in C for this part can again be found at the jpegcrop site.

Kind regards,

Nils Haeck
www.simdesign.nl



http://www.yqcomputer.com/
but
 
 
 

Lossless JPG rotation

Post by Kiss Mik » Mon, 05 Jul 2004 18:01:57

> D3?? Isn't it time to upgrade then?
Yeah, it is time to upgrade but a student like me has really not too much
money for buying new Borland products... :)

Thaks, I will have a look at it!

MikKi
 
 
 

Lossless JPG rotation

Post by Kiss Mik » Mon, 05 Jul 2004 18:23:10

I downloaded and had a look at the files and the webpage. There is a
sentence on the web page which made me curious:
'The PasJPEG 1.1 update completes the port of some utilities and add new
functionality found in the IJG v6b release (lossless transform, marker
handling).' Actually there is a file included 'jpegtran.pas' which is the
source code of a command line lossless JPEG transformation tool! :) It is
exactly what I need...!

Thank You again!

MikKi
 
 
 

Lossless JPG rotation

Post by Nils Haec » Mon, 05 Jul 2004 23:58:08

> I downloaded and had a look at the files and the webpage. There is a

Yep, I know where to find stuff :)

But please also realise, even the 1.1 dates back to 1999! Since then, there
have been quite a few updates to the IJG code, particularly for lossless
conversion, that must preserve EXIF information.

Btw, if you manage to wrap this old library in a new object and get the
lossless rotation working, I'd love to get a copy.

Kind regards,

Nils Haeck
www.simdesign.nl
 
 
 

Lossless JPG rotation

Post by Kiss Mik » Tue, 06 Jul 2004 00:43:33

> Delphi 6 Personal is available for free for personal (non-commercial) use.
Thanks for the tip, I know it. Actually I need Delphi for commercial use now
but if things went good I'll buy a new version :)

MikKi
 
 
 

Lossless JPG rotation

Post by Kiss Mik » Tue, 06 Jul 2004 00:47:03

> Yep, I know where to find stuff :)
Yeah..., and I know where to ask :)

there
Yes I saw the date but at least it is something to start with. I have to
learn much about JPEG and EXIF but now I'm on the way.

I'll see what can I do with it. If I manage to get it work as I want it to,
I'll let You know about it.

MikKi
 
 
 

Lossless JPG rotation

Post by Pavel Vyma » Tue, 06 Jul 2004 00:54:37

Delphi 6 Personal is available for free for personal (non-commercial) use.
It was released (afaik) when Delphi 8 came out.

Download, register, install, use :-)

-- Pavel Vymazal (user of D6 Personal)