[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: jpegtran lossless rotation?



> The original test.jpg and the test-90-270.jpg both create the same bitmap:
> 
> -rw-r--r--   1 olaf olaf 5760054 2005-01-24 15:44 test-90-270.bmp
> -rw-r--r--   1 olaf olaf 5760054 2005-01-24 15:44 test.bmp
> 
> Comparing them with "cmp" shows no difference.
> 
> Nothing to worry about.
> 


However, not all ways seem equivalent:

-r--r--r--    1 vmunoz   vmunoz     440635 Jan 24 18:37 pict0069.jpg
-rw-r--r--    1 vmunoz   vmunoz     436513 Jan 24 19:03 l.jpg
-rw-r--r--    1 vmunoz   vmunoz     440563 Jan 24 23:24 l90.jpg
-rw-r--r--    1 vmunoz   vmunoz     436536 Jan 24 23:24 l180.jpg
-rw-r--r--    1 vmunoz   vmunoz     440586 Jan 24 23:24 l270.jpg
-rw-r--r--    1 vmunoz   vmunoz     436513 Jan 25 17:04 l360.jpg

pict0069.jpg: original picture
l.jpg: pict0069.jpg rotated 90 degrees
       jpegtran -rotate 90 -copy all l.jpg > l90.jpg
l90.jpg:  l.jpg rotated 90 degrees with jpegtran
l180.jpg: l90.jpg rotated 90 degrees with jpegtran
l270.jpg: l180.jpg rotated 90 degrees
l360.jpg: l270.jpg rotated 90 degrees

As the previous poster mentioned, after the first transformation, continuing
with jpegtran yields equivalent results when the circle is completed (l.jpg
and l360.jpg), but l270.jpg is not the same as pict0069.jpg.

As it was also noted, decoding l270.jpg and pict0069.jpg (with djpeg) yields
the same files:

vmunoz@spl09:~/tmp/rotating$ ls -l pict0069.bmp l270.bmp
-rw-r--r--    1 vmunoz   vmunoz    5760054 Jan 25 17:08 l270.bmp
-rw-r--r--    1 vmunoz   vmunoz    5760054 Jan 25 17:08 pict0069.bmp
vmunoz@spl09:~/tmp/rotating$ cmp pict0069.bmp l270.bmp
vmunoz@spl09:~/tmp/rotating$ 

But decoding l.jpg and then rotating it, does not:

-rw-r--r--    1 vmunoz   vmunoz    5760054 Jan 25 17:48 l-convert_rotate_270.bmp
-rw-r--r--    1 vmunoz   vmunoz    5760054 Jan 25 17:28 l-convert_rotate_-90.bmp
-rw-r--r--    1 vmunoz   vmunoz    5760054 Jan 25 17:31 l-gimp_rotate_270.bmp
-rw-r--r--    1 vmunoz   vmunoz    5760054 Jan 25 17:08 pict0069.bmp

I rotated l.bmp with convert (-90 and 270 degrees, which show no difference
with 'cmp'), and with gimp (270 degrees). gimp and convert conversions
differ slightly:

vmunoz@spl09:~/tmp/rotating$ cmp -l l-gimp_rotate_270.bmp l-convert_rotate_270.bmp 
39  22   0
40  13   0
43  22   0
44  13   0

But they both differ from pict0069.bmp in many points:

vmunoz@spl09:~/tmp/rotating$ cmp -l pict0069.bmp l-convert_rotate_270.bmp
36   0 344
37   0 127
(...1101508 lines of output)
5760047  75  76
5760049  47  51

I don't know if these differences are relevant, but I guess, if I want to be
sure I'm preserving every bit of information :-), then I should use jpegtran to
rotate and then decode, not decode and then rotate.

Regards,

					Victor
	



Reply to: