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
iOS-only (notavailableonMacCatalyst): copies a file from camera-roll, that is prefixed with "assets-library://asset/asset.JPG?..."
449
-
to a specific destination. It will download the original from iCloud if necessary.
448
+
*Not available on Mac Catalyst.*
450
449
451
-
If width and height is > 0, the image will be resized to a specific size and a specific compression rate.
452
-
If scale is below 1, the image will be scaled according to the scale-factor (between0.0and1.0)
453
-
The resizeMode is also considered.
450
+
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.
454
451
455
-
*Video-Support:*
452
+
#### Parameters
453
+
454
+
##### `imageUri` string (required)
455
+
456
+
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'`.
464
+
465
+
##### `width` number (required)
466
+
467
+
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)
468
+
469
+
##### `height` number (required)
470
+
471
+
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)
472
+
473
+
##### `scale` number (optional)
474
+
475
+
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.
476
+
477
+
##### `compression` number (optional)
478
+
479
+
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.
480
+
481
+
##### `resizeMode` string (optional)
482
+
483
+
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).
484
+
485
+
#### Return value
486
+
487
+
##### `Promise<string>`
488
+
489
+
Copied file's URI.
490
+
491
+
#### Video-Support
456
492
457
493
One can use this method also to create a thumbNail from a video in a specific size.
458
494
Currently it is impossible to specify a concrete position, the OS will decide wich
@@ -462,10 +498,11 @@ To copy a video from assets-library and save it as a mp4-file, refer to copyAsse
462
498
Further information: https://developer.apple.com/reference/photos/phimagemanager/1616964-requestimageforasset
463
499
The promise will on success return the final destination of the file, as it was defined in the destPath-parameter.
0 commit comments