Live data from Hacker News

"My images are all upside down"

gigpeppers.com

21–30 of 47 posts

Re: "My images are all upside down"

#21
I ran into the exact same problem a few days ago. Luckily, ImageMagick, which I'm using for processing uploaded images, has an auto-orient [1] option that allows you to do this automatically.

Unfortunately, with JPEG this would cause some loss of quality, so we're probably going to have to keep the original quality image as well as the auto-orient'ed image to display on the site. Has anyone here worked on something similar? Any ideas on a better way to handle this would be extremely helpful.

[1] http://www.imagemagick.org/script/command-line-options.php#a...

Re: "My images are all upside down"

#22
post #5

What puzzles me is that Windows XP up to Windows 7 built-in picture viewer does not support proper orientation of iPhone photos with the original EXIF metadata in place. Picasa (on Windows) handles that perfectly, as well as (obviously) all apps in OS X. What the hell Microsoft? Is this a political thing or is there a valid technical reason?

Here's my guess as to why it would work like that. Random software package either supports the EXIF orientation or it doesn't. If it doesn't, Joe User just sees the photo rotated wrong, and they want to fix it. Joe knows he can rotate photos in Windows Picture Viewer. So he opens the file in Windows Picture Viewer and it ignores the EXIF orientation too, so he just hits rotate then goes about his business. If Windows Picture Viewer respected the EXIF orientation, it would be much less useful for this task.

Given that, OS X Preview has a different approach. It respects the EXIF orientation when you open a file, but when you re-save a file, it silently rotates the file and resets the orientation. Not sure if that is better or worse.

Re: "My images are all upside down"

#23
post #17
post #11

Earlier quoted context omitted.

Why should it rotate, when it can use the standard method for notating the proper rotation? Your camera would be a lot slower if it had to rotate 16MP images between snaps.

OTOH, it has to rotate it for display on the screen, so it can't be that computationally bad.

No it doesn't. The screen has the same orientation as the camera. When you hold the phone upside down, you are also holding the screen upside down ;)

Re: "My images are all upside down"

#24
post #19
post #8

What the hell? Why is there an orientation tag at all? Why isn't the picture just rotated by the device that takes it?

The theory is that you have the image off the sensor, and then you have metadata about the image in the EXIF fields. The debatable point is whether orientation should be treated as metadata or is inherent to the image data. On early digital cameras, this wasn't so debatable since adding an orientation sensor was a deluxe feature that really did just add another bit of data to the photo.

But the JPEG file doesn't contain the image off the sensor. That is what "RAW" images are.

Re: "My images are all upside down"

#25
post #17
post #11

Earlier quoted context omitted.

Why should it rotate, when it can use the standard method for notating the proper rotation? Your camera would be a lot slower if it had to rotate 16MP images between snaps.

OTOH, it has to rotate it for display on the screen, so it can't be that computationally bad.

I suppose the device wouldn't bother with lossless rotation when displaying on the screen. When it comes to saving the image, it has to be lossless, which would probably take a lot more computation power.

Re: "My images are all upside down"

#26
post #17

Earlier quoted context omitted.

OTOH, it has to rotate it for display on the screen, so it can't be that computationally bad.

I suppose the device wouldn't bother with lossless rotation when displaying on the screen. When it comes to saving the image, it has to be lossless, which would probably take a lot more computation power.

I'm not sure what is referred to by "lossless" rotation in the case of axis-aligned orientation. I can't see how you can do a lossy rotation.

Re: "My images are all upside down"

#27

I ran into the exact same problem a few days ago. Luckily, ImageMagick, which I'm using for processing uploaded images, has an auto-orient [1] option that allows you to do this automatically. Unfortunately, with JPEG this would cause some loss of quality, so we're probably going to have to keep the original quality image as well as the auto-orient'ed image to display on the site. Has anyone here worked on something s…

Because of math, the JPEG format does support lossless rotation, as long as the dimensions of the image are multiples of 16 pixels (or 8 depending on the file). But this requires working directly with the JPEG image data, so a package like ImageMagick that reads a formatted file into a pixel buffer, then transforms it and writes it from that buffer to a new formatted file can't support the feature.

Re: "My images are all upside down"

#28
post #7

What is the case when the photos are taken from a vertically up position? What orientation does it take? For eg: https://fbcdn-sphotos-f-a.akamaihd.net/hphotos-ak-ash3/54392... Just curious. I'm sure many food photographers will try that position too.

The EXIF orientation tag encodes all orientations: http://www.impulseadventure.com/photo/exif-orientation.html

It only encodes orientations that result from rotation around the axis perpendicular to the line of sight (in other words, the rotations that can be reversed by display software). Parent was asking about the orientation with camera above the subject pointing directly down. I don't think EXIF can encode that -- there's no reason to, since display software has no way to reverse it.

Re: "My images are all upside down"

#29
post #19

Earlier quoted context omitted.

The theory is that you have the image off the sensor, and then you have metadata about the image in the EXIF fields. The debatable point is whether orientation should be treated as metadata or is inherent to the image data. On early digital cameras, this wasn't so debatable since adding an orientation sensor was a deluxe feature that really did just add another bit of data to the photo.

But the JPEG file doesn't contain the image off the sensor. That is what "RAW" images are.

Sorry, meant the image off the image processor, which has already processed the raw data into a grid of RGB.

Re: "My images are all upside down"

#30
post #17

Earlier quoted context omitted.

OTOH, it has to rotate it for display on the screen, so it can't be that computationally bad.

No it doesn't. The screen has the same orientation as the camera. When you hold the phone upside down, you are also holding the screen upside down ;)

Right, but when you look through your photos laters, it has to transform them so up is up on the display.
Post reply on HN