On Sun, Apr 03, 2005 at 01:39:24PM -0700, Robert Fleming wrote:
> Package: libjpeg-progs
> Version: 6b-10
> Severity: grave
> Justification: causes non-serious data loss

[[This is absolutly incorrect: there is no data loss at all:
if you rotate the image back, you get exactly the original jpeg file!]]

> See http://home.comcast.net/~fleminra/jpegtran-bug/
> 
> for example input and ouput.  jpegtran incorrectly moves the bottom row of
> blocks to the top of the image.  This bug is also present in the JPEG
> source distribution at
> 
> http://www.ijg.org/files/jpegsrc.v6b.tar.gz
> 
> This appears to happen when a dimension of the input JPEG is not a multiple
> of the image block size, i.e. an image of height 256 is correctly rotated, but
> an image of height 255 is not.

Hello Robert,

Yes, this is correct, but this is the documented behaviour.
The JPEG format does not allow perfect rotation when the dimension is
not a multiple of the image block size.

Please read the jpegtran manual page, in particular:
       
       The transpose transformation has no restrictions regarding image dimen-
       sions.  The other transformations operate rather  oddly  if  the  image
       dimensions  are  not  a multiple of the iMCU size (usually 8 or 16 pix-
       els), because they can only transform complete blocks  of  DCT  coeffi-
       cient data in the desired way.

       jpegtran's  default  behavior  when  transforming  an odd-size image is
       designed to preserve exact reversibility and  mathematical  consistency
       of  the  transformation  set.  As stated, transpose is able to flip the
       entire image area.  Horizontal mirroring leaves any partial iMCU column
       at the right edge untouched, but is able to flip all rows of the image.
       Similarly, vertical mirroring leaves any partial iMCU row at the bottom
       edge  untouched, but is able to flip all columns.  The other transforms
       can be built up as sequences of transpose and flip operations; for con-
       sistency,  their  actions  on edge pixels are defined to be the same as
       the end result of the corresponding transpose-and-flip sequence.

       For practical use, you may prefer to discard any  untransformable  edge
       pixels  rather  than  having  a  strange-looking  strip along the right
       and/or bottom edges of a transformed image.  To do this, add the  -trim
       switch:

       -trim  Drop non-transformable edge blocks.

       Obviously,  a  transformation with -trim is not reversible, so strictly
       speaking jpegtran with this switch is not lossless.  Also, the expected
       mathematical  equivalences  between the transformations no longer hold.
       For example, -rot 270 -trim trims only the bottom  edge,  but  -rot  90
       -trim followed by -rot 180 -trim trims both edges.

       If  you are only interested by perfect transformation, add the -perfect
       switch:

       -perfect
              Fails with an error if the transformation is  not  perfect.  For
              example you may want to do
 
       (jpegtran  -rot  90  -perfect  foo.jpg || djpeg foo.jpg| pnmflip -r90 |
       cjpeg)
              to  do a perfect rotation if available or an approximated one if
              not.

       Note: -perfect and  lossless-crop  are  enhancements  from  http://syl-
       vana.net/jpegcrop/ that may not be available on non-Debian systems.

Cheers,
-- 
Bill. <[EMAIL PROTECTED]>

Imagine a large red swirl here. 


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to