Bug is still alive.
Env: iPad 7-gen, iPad OS 14.2
itemProvider.loadDataRepresentation(forTypeIdentifier: UTType.image.identifier) { [weak self] (data, error) in
		guard let data = data else {
				self?.parent.isPresented = false
				return
		}
		if let error = error {
				self?.parent.isPresented = false
		}
		let sourceOptions = [kCGImageSourceShouldCache: false] as CFDictionary
		guard let source = CGImageSourceCreateWithData(data as CFData, sourceOptions) else {
				return
		}
		let downsampleOptions = [
				kCGImageSourceCreateThumbnailFromImageAlways: true,
				kCGImageSourceCreateThumbnailWithTransform: true,
				kCGImageSourceThumbnailMaxPixelSize: 1024,
		] as CFDictionary
		guard let cgImage = CGImageSourceCreateThumbnailAtIndex(source, 0, downsampleOptions) else {
				return
		}
		let destinationData = NSMutableData()
		guard let imageDestination = CGImageDestinationCreateWithData(destinationData, kUTTypeJPEG, 1, nil) else {
				return
		}
		
		// Don't compress PNGs, they're too pretty
		let isPNG: Bool = {
				guard let utType = cgImage.utType else { return false }
				return (utType as String) == UTType.png.identifier
		}()
		let destinationProperties = [
				kCGImageDestinationLossyCompressionQuality: isPNG ? 1.0 : 0.75
		] as CFDictionary
		CGImageDestinationAddImage(imageDestination, cgImage, destinationProperties)
		CGImageDestinationFinalize(imageDestination)
		DispatchQueue.main.async {
				self?.parent.pickedPhoto = destinationData as Data
		}
}
Post
Replies
Boosts
Views
Activity
+1, same for me