0

Im having a really hard time finding any way to crop my captured RAW image before I send it up to the server. Im using NSURLSession and background upload so I need the image to be written to a file.

Im grabbing the RAW image data as NSData using AVCapturePhoto's fileDataRepresentation method. From there I am able to get a CIImage using CIFilter's RAW compatibility but I cant seem to find a way to go back to either NSData or writing the updated image directly to a file.

Note: Unfortunately I cant convert to Jpeg or PNG. My specific application requires that I have as few losses as possible and stick with the RAW data. The resultant file should be convertible to the .dng extension just as the raw result from fileDataRepresentation is.

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Mike Zaki
  • 11
  • 1
  • You are unable to crop image right.? – Abhirajsinh Thakore Apr 02 '18 at 05:36
  • 1
    There is no such thing as a cropped raw photo, only a jpeg (or similar) can be cropped – Joakim Danielson Apr 02 '18 at 07:00
  • Per the duplicate answer: turning a RAW file into a displayable image is like using some ingredients to bake a cake. To extend that analogy, you can't un-bake a slice of cake, nor does choosing a subset of ingredients get you a recipe for a slice. There are some uses of the DNG format that let you save post-editing instructions as metadata alongside the RAW data — that is, it tells other software which slice to cut after baking the whole cake — but there aren't any Apple APIs for such so you're limited to working directly with the Adobe DNG format or other tools. – rickster Apr 02 '18 at 20:59
  • I see, thanks for the help guys. – Mike Zaki Apr 03 '18 at 06:11

0 Answers0