expo-image-manipulator 12.0.2 → 12.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/android/build.gradle +2 -2
- package/android/src/main/java/expo/modules/imagemanipulator/FileUtils.kt +1 -0
- package/android/src/main/java/expo/modules/imagemanipulator/ManipulationArguments.kt +1 -0
- package/ios/ImageManipulatorModule.swift +2 -17
- package/ios/ImageManipulatorUtils.swift +27 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,16 @@
|
|
|
10
10
|
|
|
11
11
|
### 💡 Others
|
|
12
12
|
|
|
13
|
+
## 12.0.4 — 2024-05-13
|
|
14
|
+
|
|
15
|
+
### 🐛 Bug fixes
|
|
16
|
+
|
|
17
|
+
- On `iOS` correctly handle urls coming from the users photo library. ([#28777](https://github.com/expo/expo/pull/28777) by [@alanjhughes](https://github.com/alanjhughes))
|
|
18
|
+
|
|
19
|
+
## 12.0.3 — 2024-05-01
|
|
20
|
+
|
|
21
|
+
_This version does not introduce any user-facing changes._
|
|
22
|
+
|
|
13
23
|
## 12.0.2 — 2024-04-23
|
|
14
24
|
|
|
15
25
|
_This version does not introduce any user-facing changes._
|
package/android/build.gradle
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
apply plugin: 'com.android.library'
|
|
2
2
|
|
|
3
3
|
group = 'host.exp.exponent'
|
|
4
|
-
version = '12.0.
|
|
4
|
+
version = '12.0.4'
|
|
5
5
|
|
|
6
6
|
def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
|
|
7
7
|
apply from: expoModulesCorePlugin
|
|
@@ -14,7 +14,7 @@ android {
|
|
|
14
14
|
namespace "expo.modules.imagemanipulator"
|
|
15
15
|
defaultConfig {
|
|
16
16
|
versionCode 23
|
|
17
|
-
versionName "12.0.
|
|
17
|
+
versionName "12.0.4"
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
|
|
@@ -51,8 +51,7 @@ public class ImageManipulatorModule: Module {
|
|
|
51
51
|
}
|
|
52
52
|
return callback(.success(image))
|
|
53
53
|
}
|
|
54
|
-
if url.scheme == "assets-library" {
|
|
55
|
-
// TODO: ALAsset URLs are deprecated as of iOS 11, we should migrate to `ph://` soon.
|
|
54
|
+
if url.scheme == "ph" || url.scheme == "assets-library" {
|
|
56
55
|
return loadImageFromPhotoLibrary(url: url, callback: callback)
|
|
57
56
|
}
|
|
58
57
|
|
|
@@ -75,7 +74,7 @@ public class ImageManipulatorModule: Module {
|
|
|
75
74
|
Loads the image from user's photo library.
|
|
76
75
|
*/
|
|
77
76
|
internal func loadImageFromPhotoLibrary(url: URL, callback: @escaping LoadImageCallback) {
|
|
78
|
-
guard let asset =
|
|
77
|
+
guard let asset = retreiveAsset(from: url) else {
|
|
79
78
|
return callback(.failure(ImageNotFoundException()))
|
|
80
79
|
}
|
|
81
80
|
let size = CGSize(width: asset.pixelWidth, height: asset.pixelHeight)
|
|
@@ -119,17 +118,3 @@ public class ImageManipulatorModule: Module {
|
|
|
119
118
|
return (url: fileUrl, data: data)
|
|
120
119
|
}
|
|
121
120
|
}
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
Returns pixel data representation of the image.
|
|
125
|
-
*/
|
|
126
|
-
func imageData(from image: UIImage, format: ImageFormat, compression: Double) -> Data? {
|
|
127
|
-
switch format {
|
|
128
|
-
case .jpeg, .jpg:
|
|
129
|
-
return image.jpegData(compressionQuality: compression)
|
|
130
|
-
case .png:
|
|
131
|
-
return image.pngData()
|
|
132
|
-
case .webp:
|
|
133
|
-
return SDImageWebPCoder.shared.encodedData(with: image, format: .webP, options: [.encodeCompressionQuality: compression])
|
|
134
|
-
}
|
|
135
|
-
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import SDWebImageWebPCoder
|
|
2
|
+
import Photos
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
Returns pixel data representation of the image.
|
|
6
|
+
*/
|
|
7
|
+
func imageData(from image: UIImage, format: ImageFormat, compression: Double) -> Data? {
|
|
8
|
+
switch format {
|
|
9
|
+
case .jpeg, .jpg:
|
|
10
|
+
return image.jpegData(compressionQuality: compression)
|
|
11
|
+
case .png:
|
|
12
|
+
return image.pngData()
|
|
13
|
+
case .webp:
|
|
14
|
+
return SDImageWebPCoder.shared.encodedData(with: image, format: .webP, options: [.encodeCompressionQuality: compression])
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
Checks if we are dealing with a ph asset URL and uses the correct method to fetch it.
|
|
20
|
+
*/
|
|
21
|
+
func retreiveAsset(from url: URL) -> PHAsset? {
|
|
22
|
+
if url.scheme == "ph" {
|
|
23
|
+
let identifier = String(url.absoluteString.dropFirst(5)) // removes ph://
|
|
24
|
+
return PHAsset.fetchAssets(withLocalIdentifiers: [identifier], options: nil).firstObject
|
|
25
|
+
}
|
|
26
|
+
return PHAsset.fetchAssets(withALAssetURLs: [url], options: nil).firstObject
|
|
27
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-image-manipulator",
|
|
3
|
-
"version": "12.0.
|
|
3
|
+
"version": "12.0.4",
|
|
4
4
|
"description": "Provides functions that let you manipulation images on the local file system, eg: resize, crop.",
|
|
5
5
|
"main": "build/ImageManipulator.js",
|
|
6
6
|
"types": "build/ImageManipulator.d.ts",
|
|
@@ -39,5 +39,5 @@
|
|
|
39
39
|
"peerDependencies": {
|
|
40
40
|
"expo": "*"
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "07499b5e78e55efbf484e309ef0c200f2ac93fe5"
|
|
43
43
|
}
|