Bump picker, add patch for next version

This commit is contained in:
Eric Bailey
2025-08-28 15:08:55 -05:00
parent 2a54781ce0
commit a4aab0bdcd
4 changed files with 93 additions and 5 deletions
+1 -1
View File
@@ -146,7 +146,7 @@
"expo-image": "^2.4.0",
"expo-image-crop-tool": "^0.1.8",
"expo-image-manipulator": "~13.1.7",
"expo-image-picker": "^17.0.2",
"expo-image-picker": "17.0.4",
"expo-intent-launcher": "^12.1.5",
"expo-linear-gradient": "~14.1.5",
"expo-linking": "~7.1.5",
+81
View File
@@ -0,0 +1,81 @@
diff --git a/node_modules/expo-image-picker/ios/ImageUtils.swift b/node_modules/expo-image-picker/ios/ImageUtils.swift
index 20c86d6..1adee0b 100644
--- a/node_modules/expo-image-picker/ios/ImageUtils.swift
+++ b/node_modules/expo-image-picker/ios/ImageUtils.swift
@@ -350,25 +350,33 @@ internal struct ImageUtils {
}
/*
- * Extracts the pixel dimensions from an image file.
- * This method efficiently reads metadata without loading the entire image into memory.
+ * Extracts the visual dimensions from an image file, accounting for EXIF orientation.
+ * This ensures portrait images return portrait dimensions (height > width).
* @param url The file URL of the image to analyze
- * @return A CGSize containing the width and height, or nil if the dimensions cannot be determined
+ * @return A CGSize containing the visual width and height, or nil if the dimensions cannot be determined
*/
- static func readSizeFrom(url: URL) -> CGSize? {
- // First, try to fetch the dimensions from the image metadata as this is the fastest way
- if let imageSource = CGImageSourceCreateWithURL(url as CFURL, nil),
+ static func readVisualSizeFrom(url: URL) -> CGSize? {
+ // Try to fetch the dimensions from the image metadata as this is the fastest way
+ guard let imageSource = CGImageSourceCreateWithURL(url as CFURL, nil),
let properties = CGImageSourceCopyPropertiesAtIndex(imageSource, 0, nil) as? [CFString: Any],
let width = properties[kCGImagePropertyPixelWidth] as? CGFloat,
- let height = properties[kCGImagePropertyPixelHeight] as? CGFloat {
- return CGSize(width: width, height: height)
+ let height = properties[kCGImagePropertyPixelHeight] as? CGFloat else {
+ // Fallback: minimally decode the image using UIImage when metadata is not available
+ if let img = UIImage(contentsOfFile: url.path) {
+ return CGSize(width: img.size.width, height: img.size.height)
+ }
+ return nil
}
- // Fallback: minimally decode the image using UIImage when metadata is not available
- if let img = UIImage(contentsOfFile: url.path) {
- return CGSize(width: img.size.width, height: img.size.height)
+ // Check EXIF orientation to determine if dimensions should be swapped
+ let orientation = properties[kCGImagePropertyOrientation] as? Int ?? 1
+
+ // Orientations 5,6,7,8 (left/right rotated) need dimension swapping
+ if orientation >= 5 && orientation <= 8 {
+ return CGSize(width: height, height: width) // Swap for portrait
}
- return nil
+ // Keep as is for landscape
+ return CGSize(width: width, height: height)
}
}
diff --git a/node_modules/expo-image-picker/ios/MediaHandler.swift b/node_modules/expo-image-picker/ios/MediaHandler.swift
index 72ae9ee..6e4fbe1 100644
--- a/node_modules/expo-image-picker/ios/MediaHandler.swift
+++ b/node_modules/expo-image-picker/ios/MediaHandler.swift
@@ -97,7 +97,7 @@ internal struct MediaHandler {
imageData: imageData, orImageFileUrl: targetUrl, tryReadingFile: fileWasCopied) : nil
let exif = options.exif ? await ImageUtils.readExifFrom(mediaInfo: mediaInfo) : nil
- let size = ImageUtils.readSizeFrom(url: targetUrl) ?? .zero
+ let size = CGSize(width: image.size.width, height: image.size.height)
return AssetInfo(
assetId: asset?.localIdentifier,
@@ -144,7 +144,7 @@ internal struct MediaHandler {
let cachedUrl = targetUrl
let fileExtension = "." + cachedUrl.pathExtension
- let size = ImageUtils.readSizeFrom(url: cachedUrl) ?? .zero
+ let size = ImageUtils.readVisualSizeFrom(url: cachedUrl) ?? .zero
let fileSize = getFileSize(from: cachedUrl)
let mimeType = getMimeType(from: cachedUrl.pathExtension)
let fileName = itemProvider.suggestedName.map { $0 + fileExtension }
@@ -197,7 +197,7 @@ internal struct MediaHandler {
let exif = options.exif ? ImageUtils.readExifFrom(data: rawData) : nil
let base64 = options.base64 ? imageData?.base64EncodedString() : nil
- let size = ImageUtils.readSizeFrom(url: targetUrl) ?? .zero
+ let size = CGSize(width: image.size.width, height: image.size.height)
return AssetInfo(
assetId: selectedImage.assetIdentifier,
@@ -0,0 +1,7 @@
## expo-image-picker
Temp patch for iOS, fixes an issue where dimensions do not match the orientation
of the image.
Can be removed once https://github.com/expo/expo/pull/39230 is merged and
published.
+4 -4
View File
@@ -11339,10 +11339,10 @@ expo-image-manipulator@~13.1.7:
dependencies:
expo-image-loader "~5.1.0"
expo-image-picker@^17.0.2:
version "17.0.2"
resolved "https://registry.yarnpkg.com/expo-image-picker/-/expo-image-picker-17.0.2.tgz#79af7192b2947e54686d0ece6ccbb5f6a178a809"
integrity sha512-O74FIrc37KB4ZxC/BMUL3fEZwdmIB60As0q5XczRlzPvWismBl7GG3pPy+o5SGUI2jcepTvQAa2PcNcMbUZNYg==
expo-image-picker@17.0.4:
version "17.0.4"
resolved "https://registry.yarnpkg.com/expo-image-picker/-/expo-image-picker-17.0.4.tgz#a251949d0c1f5508fac4cd32bdc2fd835a13e204"
integrity sha512-hBFtxAKbQRfOVjf1WdEXMfRJyDXi/YKqv26pVK4wiPZ2F3nFClGKW0OL6w52pyZ7z9hhVGCi5WrWy4CwyVxOEg==
dependencies:
expo-image-loader "~6.0.0"