jpeg rotate lossless or not?
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
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
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
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
-
- Posts: 11
- Joined: 2010-03-23T20:32:14-07:00
- Authentication code: 8675308
Re: jpeg rotate lossless or not?
Is this still true? so I need directly call api of libjpeg other than IM?For lossless JPEG rotation, a program needs to manipulate the data directly in the JPEG image file.
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: jpeg rotate lossless or not?
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
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
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
-
- Posts: 1944
- Joined: 2010-08-28T11:16:00-07:00
- Authentication code: 8675308
- Location: Montreal, Canada
Re: jpeg rotate lossless or not?
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.)
-
- Posts: 10
- Joined: 2017-05-08T11:12:41-07:00
- Authentication code: 1151
Re: jpeg rotate lossless or not?
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?
How does one make ImageMagic use the metainformation upon opening?
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: jpeg rotate lossless or not?
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.
IM rotation, in multiples of 90 degrees, is lossless. Writing to JPEG, which is a lossy format, causes loss.
snibgo's IM pages: im.snibgo.com
-
- Posts: 10
- Joined: 2017-05-08T11:12:41-07:00
- Authentication code: 1151
Re: jpeg rotate lossless or not?
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.
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.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: jpeg rotate lossless or not?
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.
snibgo's IM pages: im.snibgo.com
-
- Posts: 10
- Joined: 2017-05-08T11:12:41-07:00
- Authentication code: 1151
Re: jpeg rotate lossless or not?
Thank you for your help
It's as simple as this:
result=myobject.convert("test.jpg", "-auto-orient", "test.bmp")
It's as simple as this:
result=myobject.convert("test.jpg", "-auto-orient", "test.bmp")