react-native-image-resizer icon indicating copy to clipboard operation
react-native-image-resizer copied to clipboard

How to get filesize byte ?

Open fonnypotato opened this issue 4 years ago • 1 comments

I want to resize image. If image file size > 5 mb

I can get width and height but iI don’t know How to get filesize (byte)?

Thank you 😣

fonnypotato avatar Mar 11 '21 14:03 fonnypotato

You could use react-native-file-fs to look up the stat(istics) of the file, and check the size property which returns the number of bytes.

const input: string = "file://...";
const {size} = await RNFS.stat(input);
if (size > 5000000) {
  // resize the source image
  ImageResizer.createResizedImage(...)
}

If you're already resizing the image, react-native-image-resizer returns the size property from createResizedImage already.

gerryfletch avatar Dec 22 '21 10:12 gerryfletch

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Sep 01 '22 18:09 stale[bot]

This issue has been automatically closed. Thank you for your contributions.

stale[bot] avatar Sep 08 '22 18:09 stale[bot]