I'm trying to "just" rotate some jpg & png images in a folder
`magick mogrify -rotate 180 *.jpg`
this works fine but all jpg images almost triple in size.
This doesn't seem to happen with png located in the same folder: most increase very slightly in size (a few Kb), some would also go roughly x2.5 in size.
How can this be explained? Preview on Macos does this perfectly, all be it with a few Kb change in size.
Is there a way to avoid the size increase?
-rotate more than double jpg size
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: -rotate more than double jpg size
IM reads the jpeg file, decompressing it. Then it does whatever you want. Then it re-compresses and writes the file.
For your operation, jpegtran (which is more special-purpose than IM) won't decompress and re-compress.
For your operation, jpegtran (which is more special-purpose than IM) won't decompress and re-compress.
snibgo's IM pages: im.snibgo.com
-
- Posts: 64
- Joined: 2017-10-03T10:39:52-07:00
- Authentication code: 1151
Re: -rotate more than double jpg size
Could you also use exiftool to alter the orientation tag of your jpegs?
Some apps will ignore this tag (like IM), which is why it might not work for you.
Code: Select all
exiftool -Orientation=3 <filename>
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: -rotate more than double jpg size
IM uses the orientation EXIF tag, if it exists, when doing -auto-orient. See https://imagemagick.org/script/command- ... uto-orient
-
- Posts: 64
- Joined: 2017-10-03T10:39:52-07:00
- Authentication code: 1151
Re: -rotate more than double jpg size
Good to know, though it still re-compresses when that option is chosen.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: -rotate more than double jpg size
ImageMagick always decompressed and recompressed JPGs even when only modifying the Meta data such as with -set comment. So you should probably look for some other tool as snibgo suggested above.