magick identify -format "{w: %w, h: %h, o: %[orientation]}" img.png
I run this command to determine the dimensions of an image. The problem is, sometimes the orientation is such that w and h are swapped in practice. How can I get the "actual" dimensions, which a human sees when they open a picture? Is there a built-in command to get those, or a rule regarding when a particular orientation means I have to swap w and h?
You want the -auto-orient option:
magick INPUT.JPG -auto-orient -format "{w: %w, h: %h, o: %[orientation]}" info: