Crop Filter aspect ratio breaks inside Filter Group
I'm trying to use the Crop Filter to make my photos square before applying other filters such as vignette and sepia.
If I use crop filter alone, or crop filter in a Filter Group with one other filter, it works perfectly.
When I combine 2 or more filters with the crop filter, the aspect ratio is screwed up. Instead of appearing square, the image appears squashed. It seems like the vertical and horizontal dimensions are swapped.
It seems like it's forgetting the original image orientation somehow when used in series with other filters.
Any idea of how to fix it? I love the library and really hope it will work for my project!
Thanks, Laura
Here's the working code without the aspect ratio problem:
- (void)viewDidLoad
{
stillCamera = [[GPUImageStillCamera alloc] initWithSessionPreset:AVCaptureSessionPresetPhoto cameraPosition:AVCaptureDevicePositionBack];
stillCamera.outputImageOrientation = UIInterfaceOrientationPortrait;
filter = [[GPUImageFilterGroup alloc] init];
GPUImageCropFilter *cropFilter = [[GPUImageCropFilter alloc] initWithCropRegion:CGRectMake(0.0, 0.125, 1.0, 0.75)];
GPUImageVignetteFilter *vignetteFilter = [[GPUImageVignetteFilter alloc] init];
[(GPUImageFilterGroup *)filter addFilter:vignetteFilter];
[cropFilter addTarget:vignetteFilter];
[(GPUImageFilterGroup *)filter setInitialFilters:[NSArray arrayWithObjects: cropFilter, nil]];
[(GPUImageFilterGroup *)filter setTerminalFilter:vignetteFilter];
[filter prepareForImageCapture];
[stillCamera addTarget:filter];
[filter addTarget:filterView];
}
Here's the broken code with the squashed aspect ratio when I add a third filter to the group:
- (void)viewDidLoad
{
stillCamera = [[GPUImageStillCamera alloc] initWithSessionPreset:AVCaptureSessionPresetPhoto cameraPosition:AVCaptureDevicePositionBack];
stillCamera.outputImageOrientation = UIInterfaceOrientationPortrait;
filter = [[GPUImageFilterGroup alloc] init];
GPUImageCropFilter *cropFilter = [[GPUImageCropFilter alloc] initWithCropRegion:CGRectMake(0.0, 0.125, 1.0, 0.75)];
GPUImageVignetteFilter *vignetteFilter = [[GPUImageVignetteFilter alloc] init];
[(GPUImageFilterGroup *)filter addFilter:vignetteFilter];
[cropFilter addTarget:vignetteFilter];
GPUImageSepiaFilter *sepiaFilter = [[GPUImageSepiaFilter alloc] init];
[(GPUImageFilterGroup *)filter addFilter:sepiaFilter];
[vignetteFilter addTarget:sepiaFilter];
[(GPUImageFilterGroup *)filter setInitialFilters:[NSArray arrayWithObjects: cropFilter, vignetteFilter, nil]];
[(GPUImageFilterGroup *)filter setTerminalFilter:sepiaFilter];
[filter prepareForImageCapture];
[stillCamera addTarget:filter];
[filter addTarget:filterView];
}
Is this with the latest code in the repository? I had just fixed an issue with the crop not resizing properly a few days ago. If this is with the latest code, there might still be a bug somewhere in there and I can check on that.
I downloaded the code from the repository yesterday afternoon so it should be the latest. Thank you so much for looking into it!
+1 Can confirm this is happening , everything is fine with < 3 filters in the group
+1 Problem occurs here too, with more than 3 filters in a group.
Its happening with my code too. I assume its got something to do with the orientation of the images. The crop filter's setInputRotation is faulty for some of the orientations. Can anyone please suggest something here?
It seems crop is not working for any filter group subclass, i.e. including GPUImageAmatorkaFilter