ALCameraViewController icon indicating copy to clipboard operation
ALCameraViewController copied to clipboard

Added rectangular and square cropping frame support.

Open npu3pak opened this issue 8 years ago • 2 comments

In my project, you need to crop the square areas of the images. I think this is a fairly frequent use case. Since there are now 3 cropping modes (none, square, rectangle), I replaced the allowResizing parameter with the resizingMode enumeration.

npu3pak avatar Sep 12 '17 15:09 npu3pak

@AlexLittlejohn it looks like there are some conflicts here. There are some other items that I am working on that I will eventually cherry pick into other branches (data return type, etc.) I am also running into a threading issue with this line AVCaptureStillImageOutput.jpegStillImageNSDataRepresentation(buffer) -- and I would like to include EXIF output to figure out which thread in my app is clobbering this call. For some reason, the try? of this call was deprecated in iOS 10 and now exceptions in the jpeg data are thrown (see below).

If you have any insight into this, that would be very much appreciated. It seems like dumping out the EXIF header should shed light on the situation:

Fatal Exception: NSInvalidArgumentException *** +[AVCaptureStillImageOutput jpegStillImageNSDataRepresentation:] Not a jpeg sample buffer.

`Fatal Exception: NSInvalidArgumentException 0 CoreFoundation 0x189866fe0 __exceptionPreprocess 1 libobjc.A.dylib 0x1882c8538 objc_exception_throw 2 AVFoundation 0x1912ba11c +[AVCaptureStillImageOutput jpegStillImageNSDataRepresentationForSurface:size:metadata:] 3 ALCameraViewController 0x10066277c specialized closure #1 in takePhoto(:videoOrientation:cameraPosition:cropSize:outputScale:completion:) (CameraShot.swift:26) 4 ALCameraViewController 0x10066253c closure #1 in takePhoto(:videoOrientation:cameraPosition:cropSize:outputScale:completion:) (CameraShot.swift) 5 ALCameraViewController 0x100662be8 thunk for @callee_owned (@owned CMSampleBuffer?, @owned Error?) -> () (CameraView.swift) 6 AVFoundation 0x1912b9afc -[AVCaptureStillImageOutput handleNotification:payload:] 7 CoreFoundation 0x18981530c CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK 8 CoreFoundation 0x189814b28 __CFRunLoopDoBlocks 9 CoreFoundation 0x189812e1c __CFRunLoopRun 10 CoreFoundation 0x189742da4 CFRunLoopRunSpecific 11 GraphicsServices 0x18b1ad074 GSEventRunModal 12 UIKit 0x18f9fdc9c UIApplicationMain

guard let buffer = buffer, let exifAttachments = CMGetAttachment(buffer, kCGImagePropertyExifDictionary, nil), let imageData = AVCaptureStillImageOutput.jpegStillImageNSDataRepresentation(buffer), var image = UIImage(data: imageData), let cgImage = image.cgImage else { completion(nil, nil) return }

Cyclic avatar Oct 04 '17 18:10 Cyclic

+1

daviskoh avatar Oct 30 '17 18:10 daviskoh