iOS UIImage: set image orientation without rotating the image itself -
i using avcapture+camera portrait mode capture image. when display captured image, fine--looks fine. when convert jpeg representation , convert base64 string server , server stored it, "rotated" already.
so checked image orientation before sending server: uiimageorientation.right(so there way capture image using portrait mode captured image orientation up? well, doubt after digging). after server got image, did not anything, ignored metadata orientation guess.
since image captured looks fine, want preserve how image like. however, want set image orientation up. if set image orientation, image not right anymore.
so there way set orientation without causing image rotated or after setting orientation up, how keep orientation rotate actual image make right?
- (uiimage *)removerotationforimage:(uiimage*)image { if (image.imageorientation == uiimageorientationup) return image; uigraphicsbeginimagecontextwithoptions(image.size, no, image.scale); [image drawinrect:(cgrect){0, 0, image.size}]; uiimage *normalizedimage = uigraphicsgetimagefromcurrentimagecontext(); uigraphicsendimagecontext(); return normalizedimage; }
Comments
Post a Comment