title: React Native Android] Resize image and upload to backend server
body: <p>The photos captured with the device are big. I want to upload them to my backend server after resizing them (scaling them) to more reasonable sizes (less than 800x800). I hoped to use <code>ImageEditor</code> module's <code>coprImage()</code> function, but running it with a large image results in a <code>OutOfMemory</code> exception. I assume that since the module tries to decode a large image and store it in memory, the app crashes.</p>
  
  <p>What I need is the following:</p>
  
  <p>Input</p>
  
  <pre><code>{
    width: 3100,
    height: 2500,
    uri: content://android/1 (some location in Android device)
  }
  </code></pre>
  
  <p>Output</p>
  
  <pre><code>{
    width: 800,
    height: 650,
    uri: content://android/1/resized (some location in Android device)
  }
  </code></pre>
  
  <p>Then I can grab this uri to send the picture to my backend server, and delete the resized photo from the device.</p>
  
  <p>I assume that I will have to write a <code>NativeModule</code> so I can resize an image without loading a large decoded image into memory. React Native's <code>Image</code> component uses <a href="http://frescolib.org/docs/resizing-rotating.html" rel="nofollow noreferrer">Fresco</a> to handle resizing before rendering them, but I don't think it provides a way to resize an image and temporarily save it in fs.</p>
  
  <p>Any help would be appreciated.</p>
  
  <p>References:</p>
  
  <ol>
  <li><a href="https://developer.android.com/training/displaying-bitmaps/load-bitmap.html" rel="nofollow noreferrer">https://developer.android.com/training/displaying-bitmaps/load-bitmap.html</a></li>
  <li><a href="http://frescolib.org/docs/resizing-rotating.html" rel="nofollow noreferrer">http://frescolib.org/docs/resizing-rotating.html</a></li>
  <li><a href="https://facebook.github.io/react-native/docs/images.html" rel="nofollow noreferrer">https://facebook.github.io/react-native/docs/images.html</a></li>
  <li><a href="https://stackoverflow.com/questions/3219672/memory-efficient-image-resize-in-android">Memory efficient image resize in Android</a></li>
  </ol>