title: React-native - How to open image from file path in Objective-C
body: <h2>Question</h2>
  
  <p>I have an app functionality that checks if the taken photo is blurred. Now I have followed this tutorial: <a href="https://brainhub.eu/blog/opencv-react-native-image-processing/" rel="nofollow noreferrer">Tutorial</a></p>
  
  <p>This tutorial takes a base64 representation of the image and passes it to native function.</p>
  
  <pre><code>RCT_EXPORT_METHOD(checkForBlurryImage:(NSString *)imageAsBase64 callback:(RCTResponseSenderBlock)callback){...}
  </code></pre>
  
  <p>But as you know, base64 for large images is quite slow. What I would like to do is to pass the file path where the image is saved and then open that image in <code>Objectve-C</code>. I presume, that this way the processing time will be faster with significantly less overhead.</p>
  
  <p>I have tried to implement this the following way:</p>
  
  <pre><code>RCT_EXPORT_METHOD(checkForBlurryImage2:(NSString *)imagePath callback: (RCTResponseSenderBlock)callback){
  
    UIImage *image = [UIImage imageWithContentsOfFile:imagePath];
    ...
   }
  </code></pre>
  
  <p>I have used the native api function <code>UIImage imageWithContentsOfFile</code>that reads the image from file system.</p>
  
  <h2>Problem</h2>
  
  <p>The problem is that, when the upper function return <code>nil</code>. In documentation it states, that <code>nil</code> is returned when the path is incorrect or the  image can't be opened.</p>
  
  <p>The path that I usually get from the camera looks like this:</p>
  
  <blockquote>
    <p>file:///var/mobile/Containers/Data/Application/FD0CBDBA-8B59-4618-B1A8-006FA4D33901/Library/Caches/Camera/804062B5-896F-4AAF-A35F-4F10A648B916.jpg</p>
  </blockquote>
  
  <p>What is the correct way to open the image from file path?</p>