BradLarson / GPUImage

An open source iOS framework for GPU-based image and video processing
http://www.sunsetlakesoftware.com/2012/02/12/introducing-gpuimage-framework
BSD 3-Clause "New" or "Revised" License
20.24k stars 4.61k forks source link

GPUImagePicture wrong orientation after processing #658

Open oiledCode opened 11 years ago

oiledCode commented 11 years ago

I'm facing the following problem I'm trying to process a still image grabbed from the photoLibrary . The processed image has a wrong orientation. The image is grabbed using the AssetsLibrary if it can help. Has anyone experienced the same problem?

markelsoft commented 11 years ago

I had this same problem also. I tracked it down to GPUImageFilter.m handling of the orientation. Look for the comment "Capture image with current device orientation" line: UIImage *finalImage = [UIImage imageWithCGImage:cgImageFromBytes scale:1.0 orientation:imageOrientation];

I changed this line to and it is fine.
UIImage *finalImage = [UIImage imageWithCGImage:cgImageFromBytes]; // no orientation

bkoell commented 11 years ago

If you look at the call stack you notice that the image orientation is determined by [UIDevice currentDevice] orientation]. Which always returns UIDeviceOrientationUnknown unless you call:

[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications].

RilRil commented 10 years ago

I've got the same problem.

I take a photo with the front camera which I then mirror to get an image of what we actually see on the screen : [UIImage imageWithCGImage:newImage.CGImage scale:newImage.scale orientation:UIImageOrientationUpMirrored];

then apply a GPUImageLookupFilter. The resulting processed image has the orientation of the original image ...

Any idea why ?

adhitia commented 10 years ago

i use

[GPUImageFilter imageFromCurrentlyProcessedOutputWithOrientation]

to make sure it fetch the right orientation

RilRil commented 10 years ago

I had to make a copy of the image first and then use [GPUImageFilter imageFromCurrentlyProcessedOutputWithOrientation].

Tank you for the help.