Live data from Hacker News

"My images are all upside down"

gigpeppers.com

41–47 of 47 posts

Re: "My images are all upside down"

#41

Earlier quoted context omitted.

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.

Because JPEG files don't store a value for every pixel in the image: the information is encoded very differently. By good fortune, lossless 90 and 180 degree rotations are possible for the JPEG format, but only for certain image dimensions (multiples of 8 or maybe 16, as I understand it). Some notes on what is possible can be found at http://jpegclub.org/ .

Re: "My images are all upside down"

#42

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…

[deleted]

Re: "My images are all upside down"

#43
post #38
post #30

Earlier quoted context omitted.

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

But when browsing through already stored pictures, a bit of delay is totally ok. Not so much when quickly showing some information overlaid over the picture you've just taken.

[deleted]

Re: "My images are all upside down"

#44
post #38
post #30

Earlier quoted context omitted.

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

But when browsing through already stored pictures, a bit of delay is totally ok. Not so much when quickly showing some information overlaid over the picture you've just taken.

[deleted]

Re: "My images are all upside down"

#45
post #39

Earlier quoted context omitted.

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.

Somebody covered this further up, but in more detail: It is not the rotation itself that is the problem, but saving the resultant file. If you're working directly with the pixel buffer you only do a lossless JPG rotation if the image height and width are multiples of 8 (or 16, in some situations). This is because once you've performed the rotation you'll need to save the resulting output as a JPG, and unless your dim…

Very informative, thanks a lot. I hadn't considered that JPEG rotation is more complicated than regular bitmap rotation.

Re: "My images are all upside down"

#46
post #33

This would be easier to fix in objective-c and a little custom camera wrapper application. I would expect a fix in a new OS release though. But if you need this little app let me know and I'll write it and put it on github.

If your app directly accesses the camera with AVFoundation, saving photos is a lot less automatic than you might expect. It's easy to save the raw image data but you have to generate and add just about any interesting metadata (EXIF, GPS, TIFF, etc.) explicitly. It's hard to do right--as the rather many discussions on StackOverflow suggest--and definitely a steep price to pay for a customized camera interface.

It's not that hard actually, it's just tedious. The easiest way to do it is use the CIImageProperties (http://developer.apple.com/library/mac/#documentation/Graphi...)

The better way though is to use a class like this: https://github.com/gpambrozio/GusUtils/blob/master/GusUtils/...

I see your point though - it's not trivial. I just happen to have a lot of experience in this area. I do a lot of video/imaging on the iphone.

Re: "My images are all upside down"

#47
post #39

Earlier quoted context omitted.

Somebody covered this further up, but in more detail: It is not the rotation itself that is the problem, but saving the resultant file. If you're working directly with the pixel buffer you only do a lossless JPG rotation if the image height and width are multiples of 8 (or 16, in some situations). This is because once you've performed the rotation you'll need to save the resulting output as a JPG, and unless your dim…

Very informative, thanks a lot. I hadn't considered that JPEG rotation is more complicated than regular bitmap rotation.

Doesn't the camera have the original bitmap data though? Seems like it could just rotate it before converting to JPEG.
Post reply on HN