-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 » 2018-11-15T10:41:50-07:00

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

Re: -rotate more than double jpg size

Post by snibgo » 2018-11-15T11:04:02-07:00

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 » 2018-11-18T15:35:42-07:00

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: 25734
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 » 2018-11-18T16:40:53-07:00

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 » 2018-11-18T18:23:59-07:00

Good to know, though it still re-compresses when that option is chosen.

User avatar
fmw42
Posts: 25734
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 » 2018-11-18T18:46:26-07:00

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