You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Reads the file named `filename` in the Android app's res folder and return contents. `res/drawable` is used as the parent folder for image files, `res/raw` for everything else. `encoding` can be one of `utf8` (default), `ascii`, `base64`. Use `base64` for reading binary files.
411
+
Reads the file named `filename` in the Android app's `res` folder and return contents. Only the file name (notfolder) needs to be specified. The file type will be detected from the extension and automatically located within `res/drawable` (for image files) or `res/raw` (for everything else). `encoding` can be one of `utf8` (default), `ascii`, `base64`. Use `base64` for reading binary files.
412
412
413
413
Note: Android only.
414
414
@@ -454,16 +454,52 @@ Copies the file named `filename` in the Android app's res folder and copies it t
454
454
455
455
Note: Android only. Will overwrite destPath if it already exists.
iOS-only (notavailableonMacCatalyst): copies a file from camera-roll, that is prefixed with "assets-library://asset/asset.JPG?..."
460
-
to a specific destination. It will download the original from iCloud if necessary.
459
+
*Not available on Mac Catalyst.*
461
460
462
-
If width and height is > 0, the image will be resized to a specific size and a specific compression rate.
463
-
If scale is below 1, the image will be scaled according to the scale-factor (between0.0and1.0)
464
-
The resizeMode is also considered.
461
+
Reads an image file from Camera Roll and writes to `destPath`. This method [assumes the image file to be JPEG file](https://github.com/itinance/react-native-fs/blob/f2f8f4a058cd9acfbcac3b8cf1e08fa1e9b09786/RNFSManager.m#L752-L753). This method will download the original from iCloud if necessary.
465
462
466
-
*Video-Support:*
463
+
#### Parameters
464
+
465
+
##### `imageUri` string (required)
466
+
467
+
URI of a file in Camera Roll. Can be [either of the following formats](https://github.com/itinance/react-native-fs/blob/f2f8f4a058cd9acfbcac3b8cf1e08fa1e9b09786/RNFSManager.m#L781-L785):
Destination to which the copied file will be saved, e.g. `RNFS.TemporaryDirectoryPath + 'example.jpg'`.
475
+
476
+
##### `width` number (required)
477
+
478
+
Copied file's image width will be resized to `width`. [If 0 is provided, width won't be resized.](https://github.com/itinance/react-native-fs/blob/f2f8f4a058cd9acfbcac3b8cf1e08fa1e9b09786/RNFSManager.m#L808)
479
+
480
+
##### `height` number (required)
481
+
482
+
Copied file's image height will be resized to `height`. [If 0 is provided, height won't be resized.](https://github.com/itinance/react-native-fs/blob/f2f8f4a058cd9acfbcac3b8cf1e08fa1e9b09786/RNFSManager.m#L808)
483
+
484
+
##### `scale` number (optional)
485
+
486
+
Copied file's image will be scaled proportional to `scale` factor from `width` x `height`. If both `width` and `height` are 0, the image won't scale. Range is [0.0, 1.0] and default is 1.0.
487
+
488
+
##### `compression` number (optional)
489
+
490
+
Quality of copied file's image. The value 0.0 represents the maximum compression (orlowestquality) while the value 1.0 represents the least compression (orbestquality). Range is [0.0, 1.0] and default is 1.0.
491
+
492
+
##### `resizeMode` string (optional)
493
+
494
+
If `resizeMode` is 'contain', copied file's image will be scaled so that its larger dimension fits `width` x `height`. If `resizeMode` is other value than 'contain', the image will be scaled so that it completely fills `width` x `height`. Default is 'contain'. Refer to [PHImageContentMode](https://developer.apple.com/documentation/photokit/phimagecontentmode).
495
+
496
+
#### Return value
497
+
498
+
##### `Promise<string>`
499
+
500
+
Copied file's URI.
501
+
502
+
#### Video-Support
467
503
468
504
One can use this method also to create a thumbNail from a video in a specific size.
469
505
Currently it is impossible to specify a concrete position, the OS will decide wich
@@ -473,10 +509,11 @@ To copy a video from assets-library and save it as a mp4-file, refer to copyAsse
473
509
Further information: https://developer.apple.com/reference/photos/phimagemanager/1616964-requestimageforasset
474
510
The promise will on success return the final destination of the file, as it was defined in the destPath-parameter.
0 commit comments