-rotate more than double jpg size

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
coolnodje
Posts: 1
Joined: 2018-11-15T10:33:28-07:00
Authentication code: 1152

-rotate more than double jpg size

Post by coolnodje »

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?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: -rotate more than double jpg size

Post by snibgo »

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.
snibgo's IM pages: im.snibgo.com
muccigrosso
Posts: 64
Joined: 2017-10-03T10:39:52-07:00
Authentication code: 1151

Re: -rotate more than double jpg size

Post by muccigrosso »

Could you also use exiftool to alter the orientation tag of your jpegs?

Code: Select all

exiftool -Orientation=3 <filename>
Some apps will ignore this tag (like IM), which is why it might not work for you.
User avatar
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

Post by fmw42 »

IM uses the orientation EXIF tag, if it exists, when doing -auto-orient. See https://imagemagick.org/script/command- ... uto-orient
muccigrosso
Posts: 64
Joined: 2017-10-03T10:39:52-07:00
Authentication code: 1151

Re: -rotate more than double jpg size

Post by muccigrosso »

Good to know, though it still re-compresses when that option is chosen.
User avatar
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

Post by fmw42 »

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.
Post Reply