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 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._
@@ -1,7 +1,7 @@
1
1
  apply plugin: 'com.android.library'
2
2
 
3
3
  group = 'host.exp.exponent'
4
- version = '12.0.2'
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.2"
17
+ versionName "12.0.4"
18
18
  }
19
19
  }
20
20
 
@@ -30,6 +30,7 @@ internal object FileUtils {
30
30
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
31
31
  CompressFormat.WEBP_LOSSY
32
32
  } else {
33
+ @Suppress("DEPRECATION")
33
34
  CompressFormat.WEBP
34
35
  } -> ".webp"
35
36
  else -> ".jpg"
@@ -23,6 +23,7 @@ data class SaveOptions(
23
23
  ImageFormat.WEBP -> if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
24
24
  CompressFormat.WEBP_LOSSY
25
25
  } else {
26
+ @Suppress("DEPRECATION")
26
27
  CompressFormat.WEBP
27
28
  }
28
29
  }
@@ -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 = PHAsset.fetchAssets(withALAssetURLs: [url], options: nil).firstObject else {
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.2",
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": "ee4f30ef3b5fa567ad1bf94794197f7683fdd481"
42
+ "gitHead": "07499b5e78e55efbf484e309ef0c200f2ac93fe5"
43
43
  }