Gathering detailed insights and metrics for react-native-photo-compressor
Gathering detailed insights and metrics for react-native-photo-compressor
Gathering detailed insights and metrics for react-native-photo-compressor
Gathering detailed insights and metrics for react-native-photo-compressor
npm install react-native-photo-compressor
Typescript
Module System
Min. Node Version
Node Version
NPM Version
39.5
Supply Chain
53.8
Quality
65.9
Maintenance
50
Vulnerability
94.1
License
Java (43.39%)
Objective-C++ (20.32%)
TypeScript (13.93%)
Ruby (10.07%)
Objective-C (6.52%)
JavaScript (5.34%)
C (0.26%)
Swift (0.17%)
Total Downloads
975
Last Day
1
Last Week
5
Last Month
16
Last Year
256
MIT License
2 Stars
35 Commits
1 Watchers
10 Branches
2 Contributors
Updated on Sep 05, 2024
Latest Version
0.5.0
Package Id
react-native-photo-compressor@0.5.0
Unpacked Size
53.11 kB
Size
14.50 kB
File Count
28
NPM Version
9.6.7
Node Version
18.17.0
Published on
Sep 18, 2023
Cumulative downloads
Total Downloads
Last Day
-66.7%
1
Compared to previous day
Last Week
-16.7%
5
Compared to previous week
Last Month
-38.5%
16
Compared to previous month
Last Year
-64.4%
256
Compared to previous year
2
21
React Native Turbo Modules that allow you to compress your photos by given URI and quality parameter
1npm install react-native-photo-compressor
or
1yarn add react-native-photo-compressor
Android configuration requires to enable the New Architecture:
bundle install
cd ios
RCT_NEW_ARCH_ENABLED=1 bundle exec pod install
1import { compressPhoto, compressPhotos, getSizeInBytes, deletePhoto } from 'react-native-photo-compressor';
2
3// ...
4
5const compressedPhoto = await compressPhoto('file://some/photo.png', 50);
6const remoteCompressedPhoto = await compressPhoto('http://remote/photo.png', 50);
7const namedCompressedPhoto = await compressPhoto('file://some/photo.png', 50, 'myFileName', true);
8const compressedPhotos = await compressPhotos(['file://some/photo_1.png', 'file://some/photo_2.png'], 50);
9
10const photoSize = await getSizeInBytes('file://some/photo.png');
11await deletePhoto('file://some/photo.png');
compressPhoto(uri: string, quality: number, fileName?: string, forceRewrite?: boolean): Promise<string>
Creates a compressed copy of the image at the given uri
inside a /RNPhotoCompressorImages
directory.
Also supports images from web url. In this case uri
should start with "http"
.
Argument | Info |
---|---|
uri | string, path to the photo, must contain file:// prefix |
quality | number, value from 0 to 100 (smaller number -> more compression) |
fileName? | string, optional name of the compressed photo |
forceRewrite? | boolean, optional flag to force the file to be overwritten if a file with the given name already exists. Default: false |
compressPhotos(photos: string[], quality: number, onProgress?: (progress: number) => void): Promise<string[]>
Creates a compressed copy of the images by uri from a given photos
array inside a /RNPhotoCompressorImages
directory.
Also supports images from web url. In this case uri
should start with "http"
.
Argument | Info |
---|---|
photos | string[], paths to the photo, must contain file:// prefix |
quality | number, value from 0 to 100 (smaller number -> more compression) |
rejectAll? | boolean, optional flag indicating whether to reject all if compression of one image fails, otherwise rejected images will return null. Default: true |
onProgress? | (progress: number) => void, optional callback that triggers when the image in the array has completed compression. progress returns the index of elements that have completed compression. |
getSizeInBytes(uri: string, size?: SizeType): Promise<number>
Returns the size of the file in bytes at the given uri
.
SizeType
defines the format of the return value and can be either "kb"
or "mb"
(default: "b"
).
deletePhoto(uri: string): Promise<void>;
Deletes a compressed image at a given uri
.
Note: Only works for files inside a /RNPhotoCompressorImages
directory.
If you get this error when building iOS:
/Users/user/Desktop/testApp/ios/Pods/../../node_modules/react-native/scripts/codegen/generate-legacy-interop-components.js: Permission denied
command -v node
.xcode.env
file in ios directory and replaceexport NODE_BINARY=$(command -v node)
to
export NODE_BINARY=~/your/node/path
If you want to add more functionality to this:
Or
MIT
Made with create-react-native-library
No vulnerabilities found.
No security vulnerabilities found.