Page 1 of 1

Posted: 2006-02-19T16:39:15-07:00
by anthony
You can not rotate a jpeg losslessly using IM, or any image program that actually reads and writes the image data.

However the libjpeg library installation has a jpegtran program that adjusts the jpeg data to rotate it without actaullay reading and writing the image. IE it can do it losslessly.

The same problem goes for JPEG comments and other EXIF meta data,
However other programs like jhead can also modify such information without actually touching the image data.

For more pointers see JPEG Image Handling, non-IM solutions http://www.cit.gu.edu.au/~anthony/graph ... jpg_non_im

Posted: 2006-05-04T14:44:26-07:00
by magick
90 degree rotation is lossless within ImageMagick but it is not lossless when the pixels are written back out to a JPEG image file. For lossless JPEG rotation, a program needs to manipulate the data directly in the JPEG image file.

Re: jpeg rotate lossless or not?

Posted: 2011-07-14T20:07:01-07:00
by baibaichen
For lossless JPEG rotation, a program needs to manipulate the data directly in the JPEG image file.
Is this still true? so I need directly call api of libjpeg other than IM?

Re: jpeg rotate lossless or not?

Posted: 2011-07-14T21:10:31-07:00
by anthony
Yes it is still true. As a general image processor, IM does not process images in different ways for different image file formats. You must use special tools for this special need. The same goes for lossless JPEG crop (limited to cell boundaries), or even lossless JPEG insertions (overlay), which is also possible! Though not what I would consider practical for general use.

Also note that lossless JPEG rotations have some limitations. Specifically it will roate the image but if partical blocks are present along the bottom or right edges, these will not be rotated! See the discssion at
http://www.imagemagick.org/Usage/forum_ ... 84&p=62157

Some information about this is given in...
IM Examples, Common File Formats, Lossless JPEG Processing
http://www.imagemagick.org/Usage/formats/#jpg_lossless

Re: jpeg rotate lossless or not?

Posted: 2011-07-18T11:49:28-07:00
by NicolasRobidoux
For lossless rotation outside of IM, see item 2 of http://sylvana.net/jpegcrop/jpegtran/. This is a high quality library, which runs really fast to boot. (Of course, Anthony's link above mentions it.)

Re: jpeg rotate lossless or not?

Posted: 2017-08-22T02:27:50-07:00
by FrontierDK
How about rotation inside ImageMagic? I'm using the DLL version, and I'm noticing that if I load a .JPG file, with the meta-rotation set...Imagemagic doesn't rotate it right if I convert to another format, like BMP...

How does one make ImageMagic use the metainformation upon opening?

Re: jpeg rotate lossless or not?

Posted: 2017-08-22T02:57:38-07:00
by snibgo
I don't understand your question. Please state your version of IM, the command you used, with the input file(s).

IM rotation, in multiples of 90 degrees, is lossless. Writing to JPEG, which is a lossy format, causes loss.

Re: jpeg rotate lossless or not?

Posted: 2017-08-22T04:25:24-07:00
by FrontierDK
I'm using the latest DLL version, downloaded today.

From VBscript
result=myobject.convert("test.jpg", "test.bmp")

If I load an image, which is stored "upside down" - but has the "rotate 180 degrees" exif set, it's not used.

Re: jpeg rotate lossless or not?

Posted: 2017-08-22T05:02:07-07:00
by snibgo
IM won't correct the orientation unless you tell it to. See http://www.imagemagick.org/script/comma ... uto-orient . I don't know how to do that in VB.

Re: jpeg rotate lossless or not?

Posted: 2017-08-22T05:44:46-07:00
by FrontierDK
Thank you for your help :)

It's as simple as this:
result=myobject.convert("test.jpg", "-auto-orient", "test.bmp")