Djuro
02/11/2025, 10:01 AMiOSMain
module there are issues.
Size of the selected image is returned as 0
for height and 2.233E-321
for width.
Code in 🧵Djuro
02/11/2025, 10:01 AMobject :
NSObject(),
UIImagePickerControllerDelegateProtocol,
UINavigationControllerDelegateProtocol {
override fun imagePickerController(
picker: UIImagePickerController,
didFinishPickingMediaWithInfo: Map<Any?, *>,
) {
val image =
didFinishPickingMediaWithInfo.getValue(
UIImagePickerControllerEditedImage,
) as? UIImage ?: didFinishPickingMediaWithInfo.getValue(
UIImagePickerControllerOriginalImage,
) as? UIImage
val imageAsNsData = image?.let { UIImagePNGRepresentation(it) }
imageAsNsData?.let { scopedImageAsNsData ->
image?.let { scopedImage ->
val size: CGSize = scopedImage.size.useContents { this }
Logger.e("00x99 $size")
Logger.e("00x99 h: ${size.height}")
Logger.e("00x99 w: ${size.width}")
continuation?.resume(
GalleryManager.DataWithByteArray(
data = Data(scopedImageAsNsData),
byteArray = scopedImageAsNsData.toByteArrayOrNull(),
ratio = (size.height/size.width).toFloat(),
),
)
}
}
}
}
Pamela Hill
02/13/2025, 8:46 AMPamela Hill
02/13/2025, 8:47 AMDjuro
02/13/2025, 9:44 AMCValue
scopedImage.size.useContents
It works like this
val height = scopedImage.size.useContents { this.height }
val width = scopedImage.size.useContents { this.width }
Pamela Hill
02/13/2025, 9:45 AM