Assume I have a *.jpg picture
D:\mypicture\holidayjune\pic123.jpg
How can I lossless rotate this picture by 90 clockwise and save it as
D:\mypicture\holidayjune\pic123rot.jpg
?
What do I have to change in the previous command when I want to rotate it couter clockwise by 90 deg?
Ben
How to rotate a *.jpg picture by 90 deg?
Re: How to rotate a *.jpg picture by 90 deg?
I do not think you can do a lossless rotate with IM.
clockwise -rotate 90
anticlockwise -rotate 270 ( -90 may work )
clockwise -rotate 90
anticlockwise -rotate 270 ( -90 may work )
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: How to rotate a *.jpg picture by 90 deg?
Even if the rotate 90 were lossless, just reading in a jpg and writing it out again would have some losses. JPG is a lossy compression image format. IM must read the input, decompress, recompress and write the ouput even to just copy the image. Other non-im solutions may be available. see
http://www.imagemagick.org/Usage/formats/#jpg_non-im
http://www.imagemagick.org/Usage/formats/#jpg_lossless
http://www.imagemagick.org/Usage/formats/#jpg_non-im
http://www.imagemagick.org/Usage/formats/#jpg_lossless
Last edited by fmw42 on 2012-07-02T11:19:49-07:00, edited 1 time in total.
- Dane Vandeputte
- Posts: 14
- Joined: 2012-07-01T18:26:53-07:00
- Authentication code: 13
- Location: Illinois, USA
Re: How to rotate a *.jpg picture by 90 deg?
Actually, as it turns out, one can losslessly rotate by multiples of 90 degrees (or transpose) a JPEG file by doing nothing more than rearranging and/or changing signs of the quantized DCT coefficients in each block.fmw42 wrote:Even if the rotate 90 were lossless, just reading in a jpg and writing it out again would have some losses. JPG is a lossy compression image format.
In reply to Ben, you can use the freely available jpegtran.
Use the following command to rotate input.jpg 90 degrees clockwise and save the result to output.jpg:
jpegtran -rotate 90 input.jpg output.jpg
If the input image dimensions are not multiples of the JPEG block size, you may notice a small, undesirable border along some portions of the image. To eliminate the border, use the following command instead:
jpegtran -rotate 90 -trim input.jpg output.jpg
In either case, if you want to rotate 90 degrees counter-clockwise, replace the 90 in either command with 270. Also, here is the jpegtran manual for further reference.
Digital image processing and photography enthusiast
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: How to rotate a *.jpg picture by 90 deg?
See...IM examples, Photo Handling for just a quick answer.
http://www.imagemagick.org/Usage/photos/#orient
For a complete answer, see...
Common Image file Formats, Lossless JPEG Processing (non-IM)
http://www.imagemagick.org/Usage/formats/#jpg_lossless
http://www.imagemagick.org/Usage/photos/#orient
For a complete answer, see...
Common Image file Formats, Lossless JPEG Processing (non-IM)
http://www.imagemagick.org/Usage/formats/#jpg_lossless
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/