diff --git a/README.md b/README.md index f738357f..8fe64998 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,6 @@ React Native Multiple Image Picker **(RNMIP)** enables application to pick image | 🎨 | UI Customization (numberOfColumn, spacing, primaryColor ... ) | | 🌚 | Dark Mode, Light Mode | | πŸŒ„ | Choose multiple images/video. | -| 🀐 | Compress image after selected (new) ✨ | | πŸ“¦ | Support smart album `(camera roll, selfies, panoramas, favorites, videos...)`. | | πŸ“Ί | Display video duration. | | πŸŽ† | Preview image/video. | diff --git a/android/src/main/java/com/margelo/nitro/multipleimagepicker/MultipleImagePickerImp.kt b/android/src/main/java/com/margelo/nitro/multipleimagepicker/MultipleImagePickerImp.kt index 6c78e356..6b111c3f 100644 --- a/android/src/main/java/com/margelo/nitro/multipleimagepicker/MultipleImagePickerImp.kt +++ b/android/src/main/java/com/margelo/nitro/multipleimagepicker/MultipleImagePickerImp.kt @@ -86,9 +86,6 @@ class MultipleImagePickerImp(reactContext: ReactApplicationContext?) : val maxDuration = config.maxVideoDuration?.toInt() val minDuration = config.minVideoDuration?.toInt() val allowSwipeToSelect = config.allowSwipeToSelect ?: false - val imageQuality = config.imageQuality - val videoQuality = config.videoQuality - val isMultiple = config.selectMode == SelectMode.MULTIPLE val selectMode = if (isMultiple) SelectModeConfig.MULTIPLE else SelectModeConfig.SINGLE @@ -117,15 +114,6 @@ class MultipleImagePickerImp(reactContext: ReactApplicationContext?) : maxFileSize?.let { setFilterMaxFileSize(it) } - - //TODO: set compress export -// if (imageQuality != null && imageQuality != 1.0) { -// setCompressEngine(CompressEngine()) -// } - - if (videoQuality != null && videoQuality != 1.0) { - setVideoQuality(if (videoQuality > 0.5) 1 else 0) - } } .setImageSpanCount(config.numberOfColumn?.toInt() ?: 3) .setMaxSelectNum(maxSelect) diff --git a/docs/docs/CONFIG.mdx b/docs/docs/CONFIG.mdx index 76248f35..e9f97502 100644 --- a/docs/docs/CONFIG.mdx +++ b/docs/docs/CONFIG.mdx @@ -296,32 +296,6 @@ Enable haptic feedback on preview. --- -## Compress Quality 🀐 - -### `videoQuality` - -Video quality setting for the picker. - -- **Type**: number -- **Default**: `1` -- **Required**: No -- **Platform**: iOS, Android -- **Notes**: - - iOS: Range `0`-`1` (`0`: maximum compression, `1`: highest quality) - - Android: Only `0` (low) or `1` (high) - -### `imageQuality` - -Image quality setting for the picker. - -- **Type**: number -- **Default**: `1` -- **Required**: No -- **Platform**: iOS -- **Notes**: Range `0`-`1` (`0`: maximum compression, `1`: highest quality) - ---- - ## Localization 🌐 ### `text` diff --git a/example/src/index.tsx b/example/src/index.tsx index 8edd0ae7..ff27b550 100644 --- a/example/src/index.tsx +++ b/example/src/index.tsx @@ -451,8 +451,6 @@ export default function App() { /> ) : null} - {/* Compress Quality 🀐 */} - Localization 🌐 diff --git a/ios/HybridMultipleImagePicker+Result.swift b/ios/HybridMultipleImagePicker+Result.swift index 832b89ff..f55e2606 100644 --- a/ios/HybridMultipleImagePicker+Result.swift +++ b/ios/HybridMultipleImagePicker+Result.swift @@ -9,8 +9,8 @@ import HXPhotoPicker import Photos extension HybridMultipleImagePicker { - func getResult(_ asset: PhotoAsset, _ compression: PhotoAsset.Compression) async throws -> Result { - let urlResult = try await asset.urlResult(compression) + func getResult(_ asset: PhotoAsset) async throws -> Result { + let urlResult = try await asset.urlResult() let url = urlResult.url let creationDate = Int(asset.phAsset?.creationDate?.timeIntervalSince1970 ?? 0) diff --git a/ios/HybridMultipleImagePicker.swift b/ios/HybridMultipleImagePicker.swift index 390ecbfc..93083f54 100644 --- a/ios/HybridMultipleImagePicker.swift +++ b/ios/HybridMultipleImagePicker.swift @@ -38,19 +38,6 @@ class HybridMultipleImagePicker: HybridMultipleImagePickerSpec { controller.autoDismiss = false - // - let imageQuality = config.imageQuality ?? 1.0 - - let videoQuality: Int = { - if let quality = config.videoQuality { - return Int(quality * 10) - } - - return 10 - }() - - let compression: PhotoAsset.Compression = .init(imageCompressionQuality: imageQuality, videoExportParameter: .init(preset: videoQuality == 10 ? .highQuality : videoQuality < 5 ? .mediumQuality : .lowQuality, quality: videoQuality)) - // check crop for single if let asset = pickerResult.photoAssets.first, config.selectMode == .single, config.crop != nil, asset.mediaType == .photo, asset.editedResult?.url == nil { // open crop @@ -60,7 +47,7 @@ class HybridMultipleImagePicker: HybridMultipleImagePickerSpec { photoAsset.editedResult = .some(result) Task { - let resultData = try await self.getResult(photoAsset, compression) + let resultData = try await self.getResult(photoAsset) DispatchQueue.main.async { resolved([resultData]) @@ -88,7 +75,7 @@ class HybridMultipleImagePicker: HybridMultipleImagePickerSpec { for response in pickerResult.photoAssets { group.enter() - let resultData = try await self.getResult(response, compression) + let resultData = try await self.getResult(response) data.append(resultData) group.leave() diff --git a/ios/PHAsset+Thumbnail.swift b/ios/PHAsset+Thumbnail.swift index b9e33266..b739cec0 100644 --- a/ios/PHAsset+Thumbnail.swift +++ b/ios/PHAsset+Thumbnail.swift @@ -25,7 +25,7 @@ extension PHAsset { let imgRef = try generator.copyCGImage(at: time, actualTime: nil) thumbnail = UIImage(cgImage: imgRef) } catch { - print("Lα»—i khi tαΊ‘o thumbnail: \(error)") + print("Error create thumbnail: \(error)") return nil } @@ -48,7 +48,7 @@ extension PHAsset { return nil } - let data = uiImage.jpegData(compressionQuality: 1.0) + let data = uiImage.jpegData(compressionQuality: 0.9) let fullPath = URL(fileURLWithPath: tempDirectory).appendingPathComponent("\(prefix ?? "thumb")-\(ProcessInfo.processInfo.globallyUniqueString).jpg").path diff --git a/nitrogen/generated/android/c++/JNitroConfig.hpp b/nitrogen/generated/android/c++/JNitroConfig.hpp index 02ad42df..e5e59914 100644 --- a/nitrogen/generated/android/c++/JNitroConfig.hpp +++ b/nitrogen/generated/android/c++/JNitroConfig.hpp @@ -94,10 +94,6 @@ namespace margelo::nitro::multipleimagepicker { jni::local_ref minVideoDuration = this->getFieldValue(fieldMinVideoDuration); static const auto fieldMaxFileSize = clazz->getField("maxFileSize"); jni::local_ref maxFileSize = this->getFieldValue(fieldMaxFileSize); - static const auto fieldVideoQuality = clazz->getField("videoQuality"); - jni::local_ref videoQuality = this->getFieldValue(fieldVideoQuality); - static const auto fieldImageQuality = clazz->getField("imageQuality"); - jni::local_ref imageQuality = this->getFieldValue(fieldImageQuality); static const auto fieldBackgroundDark = clazz->getField("backgroundDark"); jni::local_ref backgroundDark = this->getFieldValue(fieldBackgroundDark); static const auto fieldCrop = clazz->getField("crop"); @@ -140,8 +136,6 @@ namespace margelo::nitro::multipleimagepicker { maxVideoDuration != nullptr ? std::make_optional(maxVideoDuration->value()) : std::nullopt, minVideoDuration != nullptr ? std::make_optional(minVideoDuration->value()) : std::nullopt, maxFileSize != nullptr ? std::make_optional(maxFileSize->value()) : std::nullopt, - videoQuality != nullptr ? std::make_optional(videoQuality->value()) : std::nullopt, - imageQuality != nullptr ? std::make_optional(imageQuality->value()) : std::nullopt, backgroundDark != nullptr ? std::make_optional(backgroundDark->value()) : std::nullopt, crop != nullptr ? std::make_optional(crop->toCpp()) : std::nullopt, text != nullptr ? std::make_optional(text->toCpp()) : std::nullopt, @@ -186,8 +180,6 @@ namespace margelo::nitro::multipleimagepicker { value.maxVideoDuration.has_value() ? jni::JDouble::valueOf(value.maxVideoDuration.value()) : nullptr, value.minVideoDuration.has_value() ? jni::JDouble::valueOf(value.minVideoDuration.value()) : nullptr, value.maxFileSize.has_value() ? jni::JDouble::valueOf(value.maxFileSize.value()) : nullptr, - value.videoQuality.has_value() ? jni::JDouble::valueOf(value.videoQuality.value()) : nullptr, - value.imageQuality.has_value() ? jni::JDouble::valueOf(value.imageQuality.value()) : nullptr, value.backgroundDark.has_value() ? jni::JDouble::valueOf(value.backgroundDark.value()) : nullptr, value.crop.has_value() ? JPickerCropConfig::fromCpp(value.crop.value()) : nullptr, value.text.has_value() ? JText::fromCpp(value.text.value()) : nullptr, diff --git a/nitrogen/generated/android/kotlin/com/margelo/nitro/multipleimagepicker/NitroConfig.kt b/nitrogen/generated/android/kotlin/com/margelo/nitro/multipleimagepicker/NitroConfig.kt index 9f7e3b2a..5851eb1b 100644 --- a/nitrogen/generated/android/kotlin/com/margelo/nitro/multipleimagepicker/NitroConfig.kt +++ b/nitrogen/generated/android/kotlin/com/margelo/nitro/multipleimagepicker/NitroConfig.kt @@ -37,8 +37,6 @@ data class NitroConfig( val maxVideoDuration: Double?, val minVideoDuration: Double?, val maxFileSize: Double?, - val videoQuality: Double?, - val imageQuality: Double?, val backgroundDark: Double?, val crop: PickerCropConfig?, val text: Text?, diff --git a/nitrogen/generated/ios/swift/NitroConfig.swift b/nitrogen/generated/ios/swift/NitroConfig.swift index 2eb6f2a7..59f80ea3 100644 --- a/nitrogen/generated/ios/swift/NitroConfig.swift +++ b/nitrogen/generated/ios/swift/NitroConfig.swift @@ -18,7 +18,7 @@ public extension NitroConfig { /** * Create a new instance of `NitroConfig`. */ - 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) { + 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) { self.init(mediaType, { () -> bridge.std__vector_Result_ in var __vector = bridge.create_std__vector_Result_(selectedAssets.count) for __item in selectedAssets { @@ -121,18 +121,6 @@ public extension NitroConfig { } else { return .init() } - }(), { () -> bridge.std__optional_double_ in - if let __unwrappedValue = videoQuality { - return bridge.create_std__optional_double_(__unwrappedValue) - } else { - return .init() - } - }(), { () -> bridge.std__optional_double_ in - if let __unwrappedValue = imageQuality { - return bridge.create_std__optional_double_(__unwrappedValue) - } else { - return .init() - } }(), { () -> bridge.std__optional_double_ in if let __unwrappedValue = backgroundDark { return bridge.create_std__optional_double_(__unwrappedValue) @@ -476,40 +464,6 @@ public extension NitroConfig { } } - var videoQuality: Double? { - @inline(__always) - get { - return self.__videoQuality.value - } - @inline(__always) - set { - self.__videoQuality = { () -> bridge.std__optional_double_ in - if let __unwrappedValue = newValue { - return bridge.create_std__optional_double_(__unwrappedValue) - } else { - return .init() - } - }() - } - } - - var imageQuality: Double? { - @inline(__always) - get { - return self.__imageQuality.value - } - @inline(__always) - set { - self.__imageQuality = { () -> bridge.std__optional_double_ in - if let __unwrappedValue = newValue { - return bridge.create_std__optional_double_(__unwrappedValue) - } else { - return .init() - } - }() - } - } - var backgroundDark: Double? { @inline(__always) get { diff --git a/nitrogen/generated/shared/c++/NitroConfig.hpp b/nitrogen/generated/shared/c++/NitroConfig.hpp index 87d76ef9..a110ad02 100644 --- a/nitrogen/generated/shared/c++/NitroConfig.hpp +++ b/nitrogen/generated/shared/c++/NitroConfig.hpp @@ -76,8 +76,6 @@ namespace margelo::nitro::multipleimagepicker { std::optional maxVideoDuration SWIFT_PRIVATE; std::optional minVideoDuration SWIFT_PRIVATE; std::optional maxFileSize SWIFT_PRIVATE; - std::optional videoQuality SWIFT_PRIVATE; - std::optional imageQuality SWIFT_PRIVATE; std::optional backgroundDark SWIFT_PRIVATE; std::optional crop SWIFT_PRIVATE; std::optional text SWIFT_PRIVATE; @@ -86,7 +84,7 @@ namespace margelo::nitro::multipleimagepicker { Presentation presentation SWIFT_PRIVATE; public: - explicit NitroConfig(MediaType mediaType, std::vector selectedAssets, SelectBoxStyle selectBoxStyle, SelectMode selectMode, std::optional numberOfColumn, std::optional isPreview, std::optional primaryColor, std::optional allowedCamera, std::optional allowSwipeToSelect, std::optional spacing, std::optional isHiddenPreviewButton, std::optional isHiddenOriginalButton, std::optional isShowPreviewList, std::optional allowHapticTouchPreview, std::optional allowedLimit, std::optional maxVideo, std::optional maxSelect, std::optional maxVideoDuration, std::optional minVideoDuration, std::optional maxFileSize, std::optional videoQuality, std::optional imageQuality, std::optional backgroundDark, std::optional crop, std::optional text, Language language, Theme theme, Presentation presentation): mediaType(mediaType), selectedAssets(selectedAssets), selectBoxStyle(selectBoxStyle), selectMode(selectMode), numberOfColumn(numberOfColumn), isPreview(isPreview), primaryColor(primaryColor), allowedCamera(allowedCamera), allowSwipeToSelect(allowSwipeToSelect), spacing(spacing), isHiddenPreviewButton(isHiddenPreviewButton), isHiddenOriginalButton(isHiddenOriginalButton), isShowPreviewList(isShowPreviewList), allowHapticTouchPreview(allowHapticTouchPreview), allowedLimit(allowedLimit), maxVideo(maxVideo), maxSelect(maxSelect), maxVideoDuration(maxVideoDuration), minVideoDuration(minVideoDuration), maxFileSize(maxFileSize), videoQuality(videoQuality), imageQuality(imageQuality), backgroundDark(backgroundDark), crop(crop), text(text), language(language), theme(theme), presentation(presentation) {} + explicit NitroConfig(MediaType mediaType, std::vector selectedAssets, SelectBoxStyle selectBoxStyle, SelectMode selectMode, std::optional numberOfColumn, std::optional isPreview, std::optional primaryColor, std::optional allowedCamera, std::optional allowSwipeToSelect, std::optional spacing, std::optional isHiddenPreviewButton, std::optional isHiddenOriginalButton, std::optional isShowPreviewList, std::optional allowHapticTouchPreview, std::optional allowedLimit, std::optional maxVideo, std::optional maxSelect, std::optional maxVideoDuration, std::optional minVideoDuration, std::optional maxFileSize, std::optional backgroundDark, std::optional crop, std::optional text, Language language, Theme theme, Presentation presentation): mediaType(mediaType), selectedAssets(selectedAssets), selectBoxStyle(selectBoxStyle), selectMode(selectMode), numberOfColumn(numberOfColumn), isPreview(isPreview), primaryColor(primaryColor), allowedCamera(allowedCamera), allowSwipeToSelect(allowSwipeToSelect), spacing(spacing), isHiddenPreviewButton(isHiddenPreviewButton), isHiddenOriginalButton(isHiddenOriginalButton), isShowPreviewList(isShowPreviewList), allowHapticTouchPreview(allowHapticTouchPreview), allowedLimit(allowedLimit), maxVideo(maxVideo), maxSelect(maxSelect), maxVideoDuration(maxVideoDuration), minVideoDuration(minVideoDuration), maxFileSize(maxFileSize), backgroundDark(backgroundDark), crop(crop), text(text), language(language), theme(theme), presentation(presentation) {} }; } // namespace margelo::nitro::multipleimagepicker @@ -121,8 +119,6 @@ namespace margelo::nitro { JSIConverter>::fromJSI(runtime, obj.getProperty(runtime, "maxVideoDuration")), JSIConverter>::fromJSI(runtime, obj.getProperty(runtime, "minVideoDuration")), JSIConverter>::fromJSI(runtime, obj.getProperty(runtime, "maxFileSize")), - JSIConverter>::fromJSI(runtime, obj.getProperty(runtime, "videoQuality")), - JSIConverter>::fromJSI(runtime, obj.getProperty(runtime, "imageQuality")), JSIConverter>::fromJSI(runtime, obj.getProperty(runtime, "backgroundDark")), JSIConverter>::fromJSI(runtime, obj.getProperty(runtime, "crop")), JSIConverter>::fromJSI(runtime, obj.getProperty(runtime, "text")), @@ -153,8 +149,6 @@ namespace margelo::nitro { obj.setProperty(runtime, "maxVideoDuration", JSIConverter>::toJSI(runtime, arg.maxVideoDuration)); obj.setProperty(runtime, "minVideoDuration", JSIConverter>::toJSI(runtime, arg.minVideoDuration)); obj.setProperty(runtime, "maxFileSize", JSIConverter>::toJSI(runtime, arg.maxFileSize)); - obj.setProperty(runtime, "videoQuality", JSIConverter>::toJSI(runtime, arg.videoQuality)); - obj.setProperty(runtime, "imageQuality", JSIConverter>::toJSI(runtime, arg.imageQuality)); obj.setProperty(runtime, "backgroundDark", JSIConverter>::toJSI(runtime, arg.backgroundDark)); obj.setProperty(runtime, "crop", JSIConverter>::toJSI(runtime, arg.crop)); obj.setProperty(runtime, "text", JSIConverter>::toJSI(runtime, arg.text)); @@ -188,8 +182,6 @@ namespace margelo::nitro { if (!JSIConverter>::canConvert(runtime, obj.getProperty(runtime, "maxVideoDuration"))) return false; if (!JSIConverter>::canConvert(runtime, obj.getProperty(runtime, "minVideoDuration"))) return false; if (!JSIConverter>::canConvert(runtime, obj.getProperty(runtime, "maxFileSize"))) return false; - if (!JSIConverter>::canConvert(runtime, obj.getProperty(runtime, "videoQuality"))) return false; - if (!JSIConverter>::canConvert(runtime, obj.getProperty(runtime, "imageQuality"))) return false; if (!JSIConverter>::canConvert(runtime, obj.getProperty(runtime, "backgroundDark"))) return false; if (!JSIConverter>::canConvert(runtime, obj.getProperty(runtime, "crop"))) return false; if (!JSIConverter>::canConvert(runtime, obj.getProperty(runtime, "text"))) return false; diff --git a/src/types/config.ts b/src/types/config.ts index c2bcdab2..83939033 100644 --- a/src/types/config.ts +++ b/src/types/config.ts @@ -197,62 +197,6 @@ export interface NitroConfig { */ maxFileSize?: number - /** - * Video quality setting for the picker. - * Platform-specific quality settings: - * - * @type {number} - * @platform ios, android - * - * @ios - * - Range: 0 to 1 - * - 0: Maximum compression, lowest quality - * - 1: No compression, highest quality - * - * @android - * - Only two options: - * - 0: Low quality - * - 1: High quality - * - * @default 1 - * - * @example - * ```ts - * // iOS: 80% quality - * // Android: High quality (1) or Low quality (0) - * videoQuality: 0.8 // iOS: 80% quality, Android: Low quality - * videoQuality: 1 // Both platforms: Highest quality - * ``` - * - * @remarks - * - iOS supports continuous range from 0 to 1 - * - Android only supports two discrete values: 0 (low) or 1 (high) - * - Values between 0 and 1 on Android will be rounded - */ - videoQuality?: number - - /** - * Image quality setting for the picker. - * Determines the compression level of the selected images. - * - * @type {number} - * @value 0 - 1 - * - * @default 1 - * @platform ios - * @todo Add support for Android platform - * - * @example - * ```ts - * imageQuality: 0.8 // 80% quality - * ``` - * - * @remarks - * - Adjust this value to balance between image quality and file size. - * - Useful for optimizing performance and storage usage. - */ - imageQuality?: number - /** * Background color for dark mode in number format * @type {number}