Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,12 @@ A basic, sample app is available in [the `example` folder](https://github.com/ba

```javascript
createResizedImage(
path,
/**
* uri parameter accepts`path` or `uri`.
* This property has been tested with the output of @bam.tech/react-native-image-picker,
* react-native-vision-camera, @react-native-camera-roll/camera-roll and http link
**/
uri,
maxWidth,
maxHeight,
compressFormat,
Expand All @@ -91,6 +96,10 @@ The promise resolves with an object containing: `path`, `uri`, `name`, `size` (b
| options.mode | Similar to [react-native Image's resizeMode](https://reactnative.dev/docs/image#resizemode): either `contain` (the default), `cover`, or `stretch`. `contain` will fit the image within `width` and `height`, preserving its ratio. `cover` preserves the aspect ratio, and makes sure the image is at least `width` wide or `height` tall. `stretch` will resize the image to exactly `width` and `height`. |
| options.onlyScaleDown | If `true`, will never enlarge the image, and will only make it smaller. |

# Limitations

- If you are using `@react-native-camera-roll/camera-roll` **with new architecture enabled this library is not going to work**. If you try to display an image with the `uri` of the library using `<Image />` you are going to have the following error: `No suitable image URL loader found for ph://...`. This error come from the ReactNative `ImageLoader`, which is the one we are currently using. Help/PR for solving this are welcome. Until then, we recommend using `react-native-image-picker`.

## 👉 About Bam

We are a 100 people company developing and designing multiplatform applications with [React Native](https://www.bam.tech/agence-react-native-paris) using the Lean & Agile methodology. To get more information on the solutions that would suit your needs, feel free to get in touch by [email](mailto://[email protected]) or through or [contact form](https://www.bam.tech/en/contact)!
Expand Down
6 changes: 6 additions & 0 deletions example/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"
android:maxSdkVersion="32" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

<application
android:name=".MainApplication"
Expand Down
1 change: 1 addition & 0 deletions example/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ buildscript {
minSdkVersion = 21
compileSdkVersion = 33
targetSdkVersion = 33
kotlinVersion = "1.6.20"

// We use NDK 23 which has both M1 support and is the side-by-side NDK version from AGP.
ndkVersion = "23.1.7779620"
Expand Down
22 changes: 18 additions & 4 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,8 @@ PODS:
- React-jsinspector (0.71.8)
- React-logger (0.71.8):
- glog
- react-native-cameraroll (5.7.2):
- React-Core
- react-native-image-picker (4.10.3):
- React-Core
- react-native-image-resizer (3.0.5):
Expand Down Expand Up @@ -418,6 +420,10 @@ PODS:
- React-logger (= 0.71.8)
- React-perflogger (= 0.71.8)
- SocketRocket (0.6.0)
- VisionCamera (2.15.6):
- React
- React-callinvoker
- React-Core
- Yoga (1.14.0)
- YogaKit (1.18.1):
- Yoga (~> 1.14)
Expand Down Expand Up @@ -468,6 +474,7 @@ DEPENDENCIES:
- React-jsiexecutor (from `../node_modules/react-native/ReactCommon/jsiexecutor`)
- React-jsinspector (from `../node_modules/react-native/ReactCommon/jsinspector`)
- React-logger (from `../node_modules/react-native/ReactCommon/logger`)
- "react-native-cameraroll (from `../node_modules/@react-native-camera-roll/camera-roll`)"
- react-native-image-picker (from `../node_modules/react-native-image-picker`)
- react-native-image-resizer (from `../..`)
- React-perflogger (from `../node_modules/react-native/ReactCommon/reactperflogger`)
Expand All @@ -483,6 +490,7 @@ DEPENDENCIES:
- React-RCTVibration (from `../node_modules/react-native/Libraries/Vibration`)
- React-runtimeexecutor (from `../node_modules/react-native/ReactCommon/runtimeexecutor`)
- ReactCommon/turbomodule/core (from `../node_modules/react-native/ReactCommon`)
- VisionCamera (from `../node_modules/react-native-vision-camera`)
- Yoga (from `../node_modules/react-native/ReactCommon/yoga`)

SPEC REPOS:
Expand Down Expand Up @@ -544,6 +552,8 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native/ReactCommon/jsinspector"
React-logger:
:path: "../node_modules/react-native/ReactCommon/logger"
react-native-cameraroll:
:path: "../node_modules/@react-native-camera-roll/camera-roll"
react-native-image-picker:
:path: "../node_modules/react-native-image-picker"
react-native-image-resizer:
Expand Down Expand Up @@ -574,13 +584,15 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native/ReactCommon/runtimeexecutor"
ReactCommon:
:path: "../node_modules/react-native/ReactCommon"
VisionCamera:
:path: "../node_modules/react-native-vision-camera"
Yoga:
:path: "../node_modules/react-native/ReactCommon/yoga"

SPEC CHECKSUMS:
boost: 57d2868c099736d80fcd648bf211b4431e51a558
boost: a7c83b31436843459a1961bfd74b96033dc77234
CocoaAsyncSocket: 065fd1e645c7abab64f7a6a2007a48038fdc6a99
DoubleConversion: 5189b271737e1565bdce30deb4a08d647e3f5f54
DoubleConversion: 831926d9b8bf8166fd87886c4abab286c2422662
FBLazyVector: f637f31eacba90d4fdeff3fa41608b8f361c173b
FBReactNativeSpec: 0d9a4f4de7ab614c49e98c00aedfd3bfbda33d59
Flipper: 26fc4b7382499f1281eb8cb921e5c3ad6de91fe0
Expand All @@ -593,7 +605,7 @@ SPEC CHECKSUMS:
Flipper-RSocket: d9d9ade67cbecf6ac10730304bf5607266dd2541
FlipperKit: cbdee19bdd4e7f05472a66ce290f1b729ba3cb86
fmt: ff9d55029c625d3757ed641535fd4a75fedc7ce9
glog: 04b94705f318337d7ead9e6d17c019bd9b1f6b1b
glog: 476ee3e89abb49e07f822b48323c51c57124b572
hermes-engine: 47986d26692ae75ee7a17ab049caee8864f855de
libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913
OpenSSL-Universal: ebc357f1e6bc71fa463ccb2fe676756aff50e88c
Expand All @@ -611,6 +623,7 @@ SPEC CHECKSUMS:
React-jsiexecutor: 747911ab5921641b4ed7e4900065896597142125
React-jsinspector: c712f9e3bb9ba4122d6b82b4f906448b8a281580
React-logger: 342f358b8decfbf8f272367f4eacf4b6154061be
react-native-cameraroll: 134805127580aed23403b8c2cb1548920dd77b3a
react-native-image-picker: 60f4246eb5bb7187fc15638a8c1f13abd3820695
react-native-image-resizer: 00ceb0e05586c7aadf061eea676957a6c2ec60fa
React-perflogger: d21f182895de9d1b077f8a3cd00011095c8c9100
Expand All @@ -627,9 +640,10 @@ SPEC CHECKSUMS:
React-runtimeexecutor: 7c51ae9d4b3e9608a2366e39ccaa606aa551b9ed
ReactCommon: 85c98ab0a509e70bf5ee5d9715cf68dbf495b84c
SocketRocket: fccef3f9c5cedea1353a9ef6ada904fde10d6608
VisionCamera: 523b49054bee9dace64189ab6631cb41e8b83fe0
Yoga: 065f0b74dba4832d6e328238de46eb72c5de9556
YogaKit: f782866e155069a2cca2517aafea43200b01fd5a

PODFILE CHECKSUM: d12e6625eb5869c057639e02d65105cb9b470445

COCOAPODS: 1.12.0
COCOAPODS: 1.12.1
6 changes: 6 additions & 0 deletions example/ios/ReactNativeImageResizerExample/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,11 @@
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>NSCameraUsageDescription</key>
<string>$(PRODUCT_NAME) needs access to your Camera.</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>$(PRODUCT_NAME) needs access your photo library.</string>
<key>NSPhotoLibraryAddUsageDescription</key>
<string>$(PRODUCT_NAME) needs access your photo library.</string>
</dict>
</plist>
8 changes: 5 additions & 3 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,17 @@
"pods": "pod-install --quiet"
},
"dependencies": {
"@react-native-camera-roll/camera-roll": "^5.7.2",
"react": "18.2.0",
"react-native": "0.71.8",
"react-native-image-picker": "^4.8.4"
"react-native-image-picker": "^4.8.4",
"react-native-vision-camera": "^2.15.6"
},
"devDependencies": {
"@babel/core": "^7.20.0",
"@babel/preset-env": "^7.20.0",
"@babel/runtime": "^7.20.0",
"metro-react-native-babel-preset": "0.73.9",
"babel-plugin-module-resolver": "^4.1.0"
"babel-plugin-module-resolver": "^4.1.0",
"metro-react-native-babel-preset": "0.73.9"
}
}
Loading