Skip to content

Commit f6a44ab

Browse files
committed
♻️ refactor: remove compress when picker -> Too Slow
1 parent e50038b commit f6a44ab

File tree

12 files changed

+8
-182
lines changed

12 files changed

+8
-182
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ React Native Multiple Image Picker **(RNMIP)** enables application to pick image
2323
| 🎨 | UI Customization (numberOfColumn, spacing, primaryColor ... ) |
2424
| 🌚 | Dark Mode, Light Mode |
2525
| 🌄 | Choose multiple images/video. |
26-
| 🤐 | Compress image after selected (new) ✨ |
2726
| 📦 | Support smart album `(camera roll, selfies, panoramas, favorites, videos...)`. |
2827
| 📺 | Display video duration. |
2928
| 🎆 | Preview image/video. |

android/src/main/java/com/margelo/nitro/multipleimagepicker/MultipleImagePickerImp.kt

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,6 @@ class MultipleImagePickerImp(reactContext: ReactApplicationContext?) :
8686
val maxDuration = config.maxVideoDuration?.toInt()
8787
val minDuration = config.minVideoDuration?.toInt()
8888
val allowSwipeToSelect = config.allowSwipeToSelect ?: false
89-
val imageQuality = config.imageQuality
90-
val videoQuality = config.videoQuality
91-
9289
val isMultiple = config.selectMode == SelectMode.MULTIPLE
9390
val selectMode = if (isMultiple) SelectModeConfig.MULTIPLE else SelectModeConfig.SINGLE
9491

@@ -117,15 +114,6 @@ class MultipleImagePickerImp(reactContext: ReactApplicationContext?) :
117114
maxFileSize?.let {
118115
setFilterMaxFileSize(it)
119116
}
120-
121-
//TODO: set compress export
122-
// if (imageQuality != null && imageQuality != 1.0) {
123-
// setCompressEngine(CompressEngine())
124-
// }
125-
126-
if (videoQuality != null && videoQuality != 1.0) {
127-
setVideoQuality(if (videoQuality > 0.5) 1 else 0)
128-
}
129117
}
130118
.setImageSpanCount(config.numberOfColumn?.toInt() ?: 3)
131119
.setMaxSelectNum(maxSelect)

docs/docs/CONFIG.mdx

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -296,32 +296,6 @@ Enable haptic feedback on preview.
296296

297297
---
298298

299-
## Compress Quality 🤐
300-
301-
### `videoQuality`
302-
303-
Video quality setting for the picker.
304-
305-
- **Type**: number
306-
- **Default**: `1`
307-
- **Required**: No
308-
- **Platform**: iOS, Android
309-
- **Notes**:
310-
- iOS: Range `0`-`1` (`0`: maximum compression, `1`: highest quality)
311-
- Android: Only `0` (low) or `1` (high)
312-
313-
### `imageQuality`
314-
315-
Image quality setting for the picker.
316-
317-
- **Type**: number
318-
- **Default**: `1`
319-
- **Required**: No
320-
- **Platform**: iOS
321-
- **Notes**: Range `0`-`1` (`0`: maximum compression, `1`: highest quality)
322-
323-
---
324-
325299
## Localization 🌐
326300

327301
### `text`

example/src/index.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -451,8 +451,6 @@ export default function App() {
451451
/>
452452
) : null}
453453

454-
{/* <Text style={style.title}>Compress Quality 🤐</Text> */}
455-
456454
<Text style={style.title}>Localization 🌐</Text>
457455

458456
<View style={style.section}>

ios/HybridMultipleImagePicker+Result.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import HXPhotoPicker
99
import Photos
1010

1111
extension HybridMultipleImagePicker {
12-
func getResult(_ asset: PhotoAsset, _ compression: PhotoAsset.Compression) async throws -> Result {
13-
let urlResult = try await asset.urlResult(compression)
12+
func getResult(_ asset: PhotoAsset) async throws -> Result {
13+
let urlResult = try await asset.urlResult()
1414
let url = urlResult.url
1515

1616
let creationDate = Int(asset.phAsset?.creationDate?.timeIntervalSince1970 ?? 0)

ios/HybridMultipleImagePicker.swift

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,6 @@ class HybridMultipleImagePicker: HybridMultipleImagePickerSpec {
3838

3939
controller.autoDismiss = false
4040

41-
//
42-
let imageQuality = config.imageQuality ?? 1.0
43-
44-
let videoQuality: Int = {
45-
if let quality = config.videoQuality {
46-
return Int(quality * 10)
47-
}
48-
49-
return 10
50-
}()
51-
52-
let compression: PhotoAsset.Compression = .init(imageCompressionQuality: imageQuality, videoExportParameter: .init(preset: videoQuality == 10 ? .highQuality : videoQuality < 5 ? .mediumQuality : .lowQuality, quality: videoQuality))
53-
5441
// check crop for single
5542
if let asset = pickerResult.photoAssets.first, config.selectMode == .single, config.crop != nil, asset.mediaType == .photo, asset.editedResult?.url == nil {
5643
// open crop
@@ -60,7 +47,7 @@ class HybridMultipleImagePicker: HybridMultipleImagePickerSpec {
6047
photoAsset.editedResult = .some(result)
6148

6249
Task {
63-
let resultData = try await self.getResult(photoAsset, compression)
50+
let resultData = try await self.getResult(photoAsset)
6451

6552
DispatchQueue.main.async {
6653
resolved([resultData])
@@ -88,7 +75,7 @@ class HybridMultipleImagePicker: HybridMultipleImagePickerSpec {
8875
for response in pickerResult.photoAssets {
8976
group.enter()
9077

91-
let resultData = try await self.getResult(response, compression)
78+
let resultData = try await self.getResult(response)
9279

9380
data.append(resultData)
9481
group.leave()

ios/PHAsset+Thumbnail.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ extension PHAsset {
2525
let imgRef = try generator.copyCGImage(at: time, actualTime: nil)
2626
thumbnail = UIImage(cgImage: imgRef)
2727
} catch {
28-
print("Lỗi khi tạo thumbnail: \(error)")
28+
print("Error create thumbnail: \(error)")
2929
return nil
3030
}
3131

@@ -48,7 +48,7 @@ extension PHAsset {
4848
return nil
4949
}
5050

51-
let data = uiImage.jpegData(compressionQuality: 1.0)
51+
let data = uiImage.jpegData(compressionQuality: 0.9)
5252

5353
let fullPath = URL(fileURLWithPath: tempDirectory).appendingPathComponent("\(prefix ?? "thumb")-\(ProcessInfo.processInfo.globallyUniqueString).jpg").path
5454

nitrogen/generated/android/c++/JNitroConfig.hpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,6 @@ namespace margelo::nitro::multipleimagepicker {
9494
jni::local_ref<jni::JDouble> minVideoDuration = this->getFieldValue(fieldMinVideoDuration);
9595
static const auto fieldMaxFileSize = clazz->getField<jni::JDouble>("maxFileSize");
9696
jni::local_ref<jni::JDouble> maxFileSize = this->getFieldValue(fieldMaxFileSize);
97-
static const auto fieldVideoQuality = clazz->getField<jni::JDouble>("videoQuality");
98-
jni::local_ref<jni::JDouble> videoQuality = this->getFieldValue(fieldVideoQuality);
99-
static const auto fieldImageQuality = clazz->getField<jni::JDouble>("imageQuality");
100-
jni::local_ref<jni::JDouble> imageQuality = this->getFieldValue(fieldImageQuality);
10197
static const auto fieldBackgroundDark = clazz->getField<jni::JDouble>("backgroundDark");
10298
jni::local_ref<jni::JDouble> backgroundDark = this->getFieldValue(fieldBackgroundDark);
10399
static const auto fieldCrop = clazz->getField<JPickerCropConfig>("crop");
@@ -140,8 +136,6 @@ namespace margelo::nitro::multipleimagepicker {
140136
maxVideoDuration != nullptr ? std::make_optional(maxVideoDuration->value()) : std::nullopt,
141137
minVideoDuration != nullptr ? std::make_optional(minVideoDuration->value()) : std::nullopt,
142138
maxFileSize != nullptr ? std::make_optional(maxFileSize->value()) : std::nullopt,
143-
videoQuality != nullptr ? std::make_optional(videoQuality->value()) : std::nullopt,
144-
imageQuality != nullptr ? std::make_optional(imageQuality->value()) : std::nullopt,
145139
backgroundDark != nullptr ? std::make_optional(backgroundDark->value()) : std::nullopt,
146140
crop != nullptr ? std::make_optional(crop->toCpp()) : std::nullopt,
147141
text != nullptr ? std::make_optional(text->toCpp()) : std::nullopt,
@@ -186,8 +180,6 @@ namespace margelo::nitro::multipleimagepicker {
186180
value.maxVideoDuration.has_value() ? jni::JDouble::valueOf(value.maxVideoDuration.value()) : nullptr,
187181
value.minVideoDuration.has_value() ? jni::JDouble::valueOf(value.minVideoDuration.value()) : nullptr,
188182
value.maxFileSize.has_value() ? jni::JDouble::valueOf(value.maxFileSize.value()) : nullptr,
189-
value.videoQuality.has_value() ? jni::JDouble::valueOf(value.videoQuality.value()) : nullptr,
190-
value.imageQuality.has_value() ? jni::JDouble::valueOf(value.imageQuality.value()) : nullptr,
191183
value.backgroundDark.has_value() ? jni::JDouble::valueOf(value.backgroundDark.value()) : nullptr,
192184
value.crop.has_value() ? JPickerCropConfig::fromCpp(value.crop.value()) : nullptr,
193185
value.text.has_value() ? JText::fromCpp(value.text.value()) : nullptr,

nitrogen/generated/android/kotlin/com/margelo/nitro/multipleimagepicker/NitroConfig.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ data class NitroConfig(
3737
val maxVideoDuration: Double?,
3838
val minVideoDuration: Double?,
3939
val maxFileSize: Double?,
40-
val videoQuality: Double?,
41-
val imageQuality: Double?,
4240
val backgroundDark: Double?,
4341
val crop: PickerCropConfig?,
4442
val text: Text?,

nitrogen/generated/ios/swift/NitroConfig.swift

Lines changed: 1 addition & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public extension NitroConfig {
1818
/**
1919
* Create a new instance of `NitroConfig`.
2020
*/
21-
init(mediaType: MediaType, selectedAssets: [Result], selectBoxStyle: SelectBoxStyle, selectMode: SelectMode, numberOfColumn: Double?, isPreview: Bool?, primaryColor: Double?, allowedCamera: Bool?, allowSwipeToSelect: Bool?, spacing: Double?, isHiddenPreviewButton: Bool?, isHiddenOriginalButton: Bool?, isShowPreviewList: Bool?, allowHapticTouchPreview: Bool?, allowedLimit: Bool?, maxVideo: Double?, maxSelect: Double?, maxVideoDuration: Double?, minVideoDuration: Double?, maxFileSize: Double?, videoQuality: Double?, imageQuality: Double?, backgroundDark: Double?, crop: PickerCropConfig?, text: Text?, language: Language, theme: Theme, presentation: Presentation) {
21+
init(mediaType: MediaType, selectedAssets: [Result], selectBoxStyle: SelectBoxStyle, selectMode: SelectMode, numberOfColumn: Double?, isPreview: Bool?, primaryColor: Double?, allowedCamera: Bool?, allowSwipeToSelect: Bool?, spacing: Double?, isHiddenPreviewButton: Bool?, isHiddenOriginalButton: Bool?, isShowPreviewList: Bool?, allowHapticTouchPreview: Bool?, allowedLimit: Bool?, maxVideo: Double?, maxSelect: Double?, maxVideoDuration: Double?, minVideoDuration: Double?, maxFileSize: Double?, backgroundDark: Double?, crop: PickerCropConfig?, text: Text?, language: Language, theme: Theme, presentation: Presentation) {
2222
self.init(mediaType, { () -> bridge.std__vector_Result_ in
2323
var __vector = bridge.create_std__vector_Result_(selectedAssets.count)
2424
for __item in selectedAssets {
@@ -121,18 +121,6 @@ public extension NitroConfig {
121121
} else {
122122
return .init()
123123
}
124-
}(), { () -> bridge.std__optional_double_ in
125-
if let __unwrappedValue = videoQuality {
126-
return bridge.create_std__optional_double_(__unwrappedValue)
127-
} else {
128-
return .init()
129-
}
130-
}(), { () -> bridge.std__optional_double_ in
131-
if let __unwrappedValue = imageQuality {
132-
return bridge.create_std__optional_double_(__unwrappedValue)
133-
} else {
134-
return .init()
135-
}
136124
}(), { () -> bridge.std__optional_double_ in
137125
if let __unwrappedValue = backgroundDark {
138126
return bridge.create_std__optional_double_(__unwrappedValue)
@@ -476,40 +464,6 @@ public extension NitroConfig {
476464
}
477465
}
478466

479-
var videoQuality: Double? {
480-
@inline(__always)
481-
get {
482-
return self.__videoQuality.value
483-
}
484-
@inline(__always)
485-
set {
486-
self.__videoQuality = { () -> bridge.std__optional_double_ in
487-
if let __unwrappedValue = newValue {
488-
return bridge.create_std__optional_double_(__unwrappedValue)
489-
} else {
490-
return .init()
491-
}
492-
}()
493-
}
494-
}
495-
496-
var imageQuality: Double? {
497-
@inline(__always)
498-
get {
499-
return self.__imageQuality.value
500-
}
501-
@inline(__always)
502-
set {
503-
self.__imageQuality = { () -> bridge.std__optional_double_ in
504-
if let __unwrappedValue = newValue {
505-
return bridge.create_std__optional_double_(__unwrappedValue)
506-
} else {
507-
return .init()
508-
}
509-
}()
510-
}
511-
}
512-
513467
var backgroundDark: Double? {
514468
@inline(__always)
515469
get {

0 commit comments

Comments
 (0)