Comparing photos store by my Canon iXus 60 with those from a friend's Casio camera, I see in the Inspector More Info data that the Canon seems to store more information about the photo, in particular it has (for a portrait photo) a field... [snip]
That's because the iXus has an orientations sensor within it that detects the orientation of the camera and can record that alongside the image. The Casio (like most cameras) doesn't have an orientation sensor, so it is unable to determine which way up the image was taken.
returns Orientation 1 (Normal) for both a normal landscape photo and one taken upside down.
The sensor is likely detecting offset from horizontal. Since right-side-up and upside-down are both, essentially, horizontal, they're both recorded the same way (few people take pictures upside down 😉 )
Holding he camera at about 45° brought Orientation 1, in one case, and Orientation 6 in another.
That's probably because you weren't
quite at 45 degrees on the first shot.
As for the script, since that data is stored in the EXIF data, it should be possible to extract it via Image Events, so a slightly puffed-up version of my script should be able to orient it correctly.