Image I/O

RSS for tag

Read and write most image file formats, manage color, access image metadata using Image I/O.

Posts under Image I/O tag

62 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

iOS 18.2 ImageIO Crash
1 CoreFoundation _dataWrite + 144 2 CoreFoundation _CFWriteStreamWrite + 312 3 ImageIO IIOColorMap::writeToStream(__CFWriteStream*) + 128 4 ImageIO GlobalGIFInfo::writeToStream(__CFWriteStream*, CFRange const&) + 336 5 ImageIO GlobalGIFInfo::createDataRepresentation(CFRange const&) + 80 6 ImageIO IIO_Reader_GIF::createGlobalInfoData(IIOImageReadSession*) + 68 7 ImageIO IIOReadPlugin::callDecodeImage(IIODecodeParameter*, IIOImageType, __IOSurface**, __CVBuffer**, CGImageBlockSet**) + 608 8 ImageIO IIO_Reader::CopyImageBlockSetProc(void*, CGImageProvider*, CGRect, CGSize, __CFDictionary const*) + 696 9 ImageIO IIOImageProviderInfo::copyImageBlockSetWithOptions(CGImageProvider*, CGRect, CGSize, __CFDictionary const*) + 740 10 ImageIO IIOImageProviderInfo::CopyImageBlockSetWithOptions(void*, CGImageProvider*, CGRect, CGSize, __CFDictionary const*) + 920 11 QuartzCore CA::Render::copy_image(CGImage*, CGColorSpace*, unsigned int, double, double) + 3080 12 QuartzCore CA::Render::prepare_image(CGImage*, CGColorSpace*, unsigned int, double) + 24 13 QuartzCore CA::Layer::prepare_contents(CALayer*, CA::Transaction*) + 220 14 QuartzCore CA::Layer::prepare_commit(CA::Transaction*) + 284 15 QuartzCore CA::Context::commit_transaction(CA::Transaction*, double, double*) + 484 16 QuartzCore CA::Transaction::commit() + 648 17 QuartzCore CA::Transaction::flush_as_runloop_observer(bool) + 88 18 UIKitCore __UIApplicationFlushCATransaction + 52 19 UIKitCore ___setupUpdateSequence_block_invoke_2 + 332 20 UIKitCore __UIUpdateSequenceRun + 84 21 UIKitCore _schedulerStepScheduledMainSection + 172 22 UIKitCore _runloopSourceCallback + 92 23 CoreFoundation ___CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 28 24 CoreFoundation ___CFRunLoopDoSource0 + 176 25 CoreFoundation ___CFRunLoopDoSources0 + 244 26 CoreFoundation ___CFRunLoopRun + 840 27 CoreFoundation _CFRunLoopRunSpecific + 588 28 GraphicsServices 0x00000001ebf114c0 GSEventRunModal + 164 29 UIKitCore -[UIApplication _run] + 816 30 UIKitCore _UIApplicationMain + 340
0
0
18
53m
Open Graph Metadata & SSL Issue on iOS/macOS
Hi Team, We’re encountering an issue where Open Graph metadata (e.g., og:image) isn’t rendering properly on iOS/macOS platforms or WhatsApp previews. Here’s a brief summary of the problem: SSL Configuration: Our SSL Labs report shows a grade of B due to: Improper certificate chain setup. Outdated cipher suites (e.g., TLS_RSA_WITH_3DES). Support for deprecated TLS protocols (1.0/1.1). Frontend Observations: Metadata (e.g., og:image) is not reliably picked up on iOS/macOS crawlers. Crawlers may have issues accessing assets due to CORS or TLS limitations. What We Need: Guidance on resolving Open Graph preview issues specific to iOS/macOS environments. Best practices for ensuring compatibility with Apple’s crawlers and WhatsApp on iOS. Suggestions for optimizing server-side SSL/TLS configurations and frontend setup to improve metadata visibility. We’re currently using Next.js 14 for the frontend. Any insights or debugging tips are greatly appreciated! Thanks in advance!
1
0
126
1w
Fail to Create CGImageMetadata by key "HDRGainMap:HDRGainMapHeadroom"
I am trying to create an empty metadata, and set the HDRGainMapHeadroom at ***. However the final returned mutableMetadata doesn't contain the HDRGainMap:HDRGainMapVersion or HDRGainMap:HDRGainMapHeadroom. But iio:hasXMP exist. why? Is that the reason that the namespace HDRGainMap is private? func createHDRGainMapMetadata(version: Int, headroom: Double) -> CGImageMetadata? { // Create a mutable metadata object let mutableMetadata = CGImageMetadataCreateMutable() // Define the namespace for HDRGainMap let namespace = "HDRGainMap" let xmpKeyPath = "iio:hasXMP" let xmpValue = String(true) // Set the HDRGainMapVersion item let versionKeyPath = "\(namespace):HDRGainMapVersion" let versionValue = String(version) // Set the version value let xmpSetResult = CGImageMetadataSetValueWithPath(mutableMetadata, nil, xmpKeyPath as CFString, xmpValue as CFString) if xmpSetResult == false { print("Failed to set xmp") } // Set the version value let versionSetResult = CGImageMetadataSetValueWithPath(mutableMetadata, nil, versionKeyPath as CFString, versionValue as CFString) if versionSetResult == false { print("Failed to set HDRGainMapVersion") } // Set the HDRGainMapHeadroom item let headroomKeyPath = "\(namespace):HDRGainMapHeadroom" let headroomValue = String(headroom) // Set the headroom value let headroomSetResult = CGImageMetadataSetValueWithPath(mutableMetadata, nil, headroomKeyPath as CFString, headroomValue as CFString) if headroomSetResult == false { print("Failed to set HDRGainMapHeadroom") } return mutableMetadata }
0
0
119
1w
Intercepting incoming video and/or audio for stopping scams
I'm trying to make an app that is able to quietly run in the background. It needs to detect other apps' or the system's incoming video and/or audio, using only on-device resources to determine if it might be a scam caller. It will tap into an escalating cascade of resources to do so. For video/image scam detection, it uses OpenCV to detect faces, then refers to a known database of reported scam imagery. For audio scam calls, we defer to known techniques of voice modulation in frequency and/or amplitude. Each video and/or audio result will be relayed via notification banner as well as recorded in-app. Crucially, if the results are uncertain, users have the option to submit it to a global collaborative cloud database for investigative teams; 60 second audio snippets or series of images where faces were detected (60 second equivalent). In the end, we expect to deploy this app across most parts of Asia and Africa, thereby protecting generations of iPhone and iPad users. However, we have not been able to find a method that does this, and there is no known correspondance able to provide such technical guidance. Please assist.
0
0
99
3w
CGImageDestinationAddImageFromSource causes issues in iOS 18 / macOS 15
There seems to be an issue in iOS 18 / macOS 15 related to image thumbnail generation and/or HEIC. We are transcoding JPEG images to HEIC when they are loaded into our app (HEIC has a much lower memory footprint when loaded by Core Image, for some reason). We use Image I/O for that: guard let source = CGImageSourceCreateWithURL(inputURL, nil), let destination = CGImageDestinationCreateWithURL(outputURL, UTType.heic.identifier as CFString, 1, nil) else { throw <error> } let primaryImageIndex = CGImageSourceGetPrimaryImageIndex(source) CGImageDestinationAddImageFromSource(destination, source, primaryImageIndex, nil) When we use CGImageDestinationAddImageFromSource, we get the following warnings on the console: createImage:1445: *** ERROR: bad image size (0 x 0) rb: 0 CGImageSourceCreateThumbnailAtIndex:5195: *** ERROR: CGImageSourceCreateThumbnailAtIndex[0] - 'HJPG' - failed to create thumbnail [-67] {alw:-1, abs: 1 tra:-1 max:4620} writeImageAtIndex:1025: ⭕️ ERROR: '<app>' is trying to save an opaque image (4620x3466) with 'AlphaPremulLast'. This would unnecessarily increase the file size and will double (!!!) the required memory when decoding the image --> ignoring alpha. It seems that CGImageDestinationAddImageFromSource is trying to extract/create a thumbnail, which fails somehow. I re-wrote the last part like this: guard let primaryImage = CGImageSourceCreateImageAtIndex(source, primaryImageIndex, nil), let properties = CGImageSourceCopyPropertiesAtIndex(source, primaryImageIndex, nil) else { throw <error> } CGImageDestinationAddImage(destination, primaryImage, properties) This doesn't cause any warnings. An issue that might be related has been reported here. I've also heard from others having issues with CGImageSourceCreateThumbnailAtIndex.
0
0
190
3w
Issue import from file to photo large amount of file
Hi, i’m doing a work. i need to transfer files (photo, raw format) from sd to iphone. On my iPad pro. i need to move photo first on file, then Import to photo. now. If i do this job for few files there is no problem. if i copy more then 300 files job is not done. when i select raw file on file app, and then click on share/ save to my photo option …. Ther‘s no progress bar, no way to conclude copy with success. At least 298 photo are imported. Whitout any error or warning. Someone do the trick? can be possible to copy from file to file or import from file to photo with a progress bar display? it’s very very strange that the basic is turned off. please help me. thank you very much in advance.
0
0
132
2w
CGImageMetadataTagCreate error when create gain map tag
I extracted the gain map info from an image using let url = Bundle.main.url(forResource: "IMG_1181", withExtension: "HEIC") let source = CGImageSourceCreateWithURL(url! as CFURL, nil) let portraitData = CGImageSourceCopyAuxiliaryDataInfoAtIndex(source!, 0, kCGImageAuxiliaryDataTypeHDRGainMap) as! [AnyHashable : Any] let metaData = portraitData[kCGImageAuxiliaryDataInfoMetadata] as! CGImageMetadata Then I printed all the metadata tags func printMetadataProperties(from metadata: CGImageMetadata) { guard let tags = CGImageMetadataCopyTags(metadata) as? [CGImageMetadataTag] else { return } for tag in tags { if let prefix = CGImageMetadataTagCopyPrefix(tag) as String?, let namespace = CGImageMetadataTagCopyNamespace(tag) as String?, let key = CGImageMetadataTagCopyName(tag) as String?, let value = CGImageMetadataTagCopyValue(tag){ print("Namespace: \(namespace), Key: \(key), Prefix: \(prefix), value: \(value)") } else { } } } //Namespace: http://ns.apple.com/ImageIO/1.0/, Key: hasXMP, Prefix: iio, value: True //Namespace: http://ns.apple.com/HDRGainMap/1.0/, Key: HDRGainMapVersion, Prefix: HDRGainMap, value: 131072 //Namespace: http://ns.apple.com/HDRGainMap/1.0/, Key: HDRGainMapHeadroom, Prefix: HDRGainMap, value: 3.586325 I want to create a new CGImageMetadata and tags. But when it comes to the HDR tags. It always fails to add to metadata. let tag = CGImageMetadataTagCreate( "http://ns.apple.com/HDRGainMap/1.0/" as CFString, "HDRGainMap" as CFString, "HDRGainMapHeadroom" as CFString, .default, 3.56 as CFNumber ) let path = "\(HDRGainMap):\(HDRGainMapHeadroom)" as CFString let success = CGImageMetadataSetTagWithPath(metadata, nil, path, tag)// always false The hasXMP works fine. Is HDR a private dict for Apple?
0
0
208
Oct ’24
View error
Hi, I have a problem that I can't solve, and I hope you can help me: When I switch tabs or scroll down, the background color of the tab bar changes automatically. This happened to me with Xcode 16.0. Can yo help me please?
1
0
230
Oct ’24
Unable to Get Result from DetectHorizonRequest - Result is nil
I am using Apple’s Vision framework with DetectHorizonRequest to detect the horizon in an image. Here is my code: func processHorizonImage(_ ciImage: CIImage) async { let request = DetectHorizonRequest() do { let result = try await request.perform(on: ciImage) print(result) } catch { print(error) } } After calling the perform method, I am getting result as nil. To ensure the request's correctness, I have verified the following: The input CIImage is valid and contains a visible horizon. No errors are being thrown. The relevant frameworks are properly imported. Given that my image contains a clear horizon, why am I still not getting any results? I would appreciate any help or suggestions to resolve this issue. Thank you for your support! This is the image
0
0
287
Oct ’24
webp images cause Safari to not work properly
Hello, during the development of my website, I discovered that when there are numerous or large WebP images on the screen, the screen keeps flickering, accompanied by the phenomenon of mobile phone heating. The page returns to normal after converting to PNG. It seems that the issue is caused by the update of IOS 18. Could you please assist me in taking a look? PNG (it works) https://static.xdbbtswu.com/bbt_of/assets/test/good/#/ WebP (it doesn't work) https://static.xdbbtswu.com/bbt_of/assets/test/nogood/#/
0
0
243
Oct ’24
Heic format image incompatibility issue
I am a developer working on iOS apps. In the demo, I planned to replace the local images with Heic format instead of PNG format, but the actual test results showed abnormalities on this device, while the other test devices displayed normally Heic images are converted by the built-in image conversion function on Mac. I tested multiple Heic images, but none of them were displayed and the image information returned nil,,but PNG images can be displayed normally. device information:
6
0
410
Nov ’24
Seeking API for Advanced Auto Image Enhancement Similar to Photos App's Auto Feature
Hi everyone, I've been working with the autoAdjustmentFilters provided by Core Image, which includes filters like CIHighlightShadowAdjust, CIVibrance, and CIToneCurve. However, I’ve noticed that the results differ significantly from the "Auto" enhancement feature in the Photos app. In the Photos app, the Auto function seems to adjust multiple parameters such as contrast, exposure, white balance, highlights, and shadows in a more advanced manner. Is there an API or a framework available that can replicate the more sophisticated "Auto" adjustments as seen in the Photos app? Or would I need to manually combine filters (like CIExposureAdjust, CIWhitePointAdjust, etc.) to approximate this functionality? Any insights or recommendations on how to achieve this would be greatly appreciated. Thank you!
0
0
255
Oct ’24
How to share PHAsset with UIActivityViewController like Photos App?
I am building an app about photos and I want to create a photo sharing feature like Apple's Photos App. Please see Steps to Reproduce and attached project. The current share method has the following issues The file name of the shared photo changes to “FullSizeRender”. The creation and update dates of shared photos will change to the date they were edited or shared. I want to ensure that the following conditions are definitely met Share the latest edited version. The creation date should be when the original photo was first created. How can I improve the code? STEPS TO REPRODUCE class PHAssetShareManager { static func shareAssets(_ assets: [PHAsset], from viewController: UIViewController, sourceView: UIView) { let manager = PHAssetResourceManager.default() var filesToShare: [URL] = [] let group = DispatchGroup() for asset in assets { group.enter() getAssetFile(asset, resourceManager: manager) { fileURL in if let fileURL = fileURL { filesToShare.append(fileURL) } group.leave() } } group.notify(queue: .main) { self.presentShareSheet(filesToShare, from: viewController, sourceView: sourceView) } } private static func getAssetFile(_ asset: PHAsset, resourceManager: PHAssetResourceManager, completion: @escaping (URL?) -> Void) { print("getAssetFile") let resources: [PHAssetResource] switch asset.mediaType { case .image: if asset.mediaSubtypes.contains(.photoLive) { // let editedResources = PHAssetResource.assetResources(for: asset).filter { $0.type == .fullSizePairedVideo } // let originalResources = PHAssetResource.assetResources(for: asset).filter { $0.type == .pairedVideo } let editedResources = PHAssetResource.assetResources(for: asset).filter { $0.type == .fullSizePhoto } let originalResources = PHAssetResource.assetResources(for: asset).filter { $0.type == .photo } resources = editedResources.isEmpty ? originalResources : editedResources } else { let editedResources = PHAssetResource.assetResources(for: asset).filter { $0.type == .fullSizePhoto } let originalResources = PHAssetResource.assetResources(for: asset).filter { $0.type == .photo } resources = editedResources.isEmpty ? originalResources : editedResources } case .video: let editedResources = PHAssetResource.assetResources(for: asset).filter { $0.type == .fullSizeVideo } let originalResources = PHAssetResource.assetResources(for: asset).filter { $0.type == .video } resources = editedResources.isEmpty ? originalResources : editedResources default: print("Unsupported media type") completion(nil) return } guard let resource = resources.first else { print("No resource found") completion(nil) return } let fileName = resource.originalFilename let tempDirectoryURL = FileManager.default.temporaryDirectory let localURL = tempDirectoryURL.appendingPathComponent(fileName) // Delete existing files and reset cache if FileManager.default.fileExists(atPath: localURL.path) { do { try FileManager.default.removeItem(at: localURL) } catch { print("Error removing existing file: \(error)") } } let options = PHAssetResourceRequestOptions() options.isNetworkAccessAllowed = true resourceManager.writeData(for: resource, toFile: localURL, options: options) { (error) in if let error = error { print("Error writing asset data: \(error)") completion(nil) } else { completion(localURL) } } } private static func presentShareSheet(_ items: [Any], from viewController: UIViewController, sourceView: UIView) { print("presentShareSheet") let activityViewController = UIActivityViewController(activityItems: items, applicationActivities: nil) if UIDevice.current.userInterfaceIdiom == .pad { activityViewController.popoverPresentationController?.sourceView = sourceView activityViewController.popoverPresentationController?.sourceRect = sourceView.bounds } viewController.present(activityViewController, animated: true, completion: nil) } }```
0
0
247
Oct ’24
IIOScanner and PHImageIODecoder crash
I have a user who keeps crashing on his iOS 18 device, I need some help~ Exception 1, Code 26, Subcode 8 > Attempted to dereference garbage pointer 0x1a. 0 ImageIO IIOScanner::getVal32() + 36 1 ImageIO PSDReadPlugin::initialize(IIODictionary*) + 620 2 ImageIO PSDReadPlugin::initialize(IIODictionary*) + 620 3 ImageIO IIOReadPlugin::callInitialize() + 400 4 ImageIO IIO_Reader::initImageAtOffset(CGImagePlugin*, unsigned long, unsigned long, unsigned long) + 164 5 ImageIO IIOImageSource::makeImagePlus(unsigned long, IIODictionary*) + 832 6 ImageIO IIOImageSource::getPropertiesAtIndexInternal(unsigned long, IIODictionary*) + 72 7 ImageIO IIOImageSource::createThumbnailAtIndex(unsigned long, IIODictionary*, int*) + 1352 8 ImageIO CGImageSourceCreateThumbnailAtIndex + 740 9 Photos _createDecodedImageUsingImageIOWithFileUrlOrData + 856 10 Photos __91-[PHImageIODecoder decodeImageFromData:orFileURL:options:existingRequestHandle:completion:]_block_invoke_2 + 176 11 libdispatch.dylib _dispatch_call_block_and_release + 32 12 libdispatch.dylib _dispatch_client_callout + 20 13 libdispatch.dylib _dispatch_continuation_pop + 596 14 libdispatch.dylib _dispatch_async_redirect_invoke + 580 15 libdispatch.dylib _dispatch_root_queue_drain + 392 16 libdispatch.dylib _dispatch_worker_thread2 + 156 17 libsystem_pthread.dylib _pthread_wqthread + 228
1
0
247
Sep ’24
UIKit in SwiftUI memory leak while displaying images
I'm using UIKit to display a long list of large images inside a SwiftUI ScrollView and LazyHStack using UIViewControllerRepresentable. When an image is loaded, I'm using SDWebImage to load the image from the disk. As the user navigates through the list and continues to load more images, more memory is used and is never cleared, even as the images are unloaded by the LazyHStack. Eventually, the app reaches the memory limit and crashes. This issue persists if I load the image with UIImage(contentsOfFile: ...) instead of SDWebImage. How can I free the memory used by UIImage when the view is removed? ScrollView(.horizontal, showsIndicators: false) { LazyHStack(spacing: 16) { ForEach(allItems) { item in TestImageDisplayRepresentable(item: item) .frame(width: geometry.size.width, height: geometry.size.height) .id(item.id) } } .scrollTargetLayout() } import UIKit import SwiftUI import SDWebImage class TestImageDisplay: UIViewController { var item: TestItem init(item: TestItem) { self.item = item super.init(nibName: nil, bundle: nil) } required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } override func viewDidLoad() { super.viewDidLoad() let imageView = UIImageView(frame: CGRect(x: 0, y: 0, width: 200, height: 200)) imageView.center = view.center view.addSubview(imageView) imageView.sd_setImage(with: item.imageURL, placeholder: nil) } } struct TestImageDisplayRepresentable: UIViewControllerRepresentable { var item: TestItem func makeUIViewController(context: Context) -> TestImageDisplay { return TestImageDisplay(item: item) } func updateUIViewController(_ uiViewController: TestImageDisplay, context: Context) { uiViewController.item = item } }
0
0
354
Sep ’24
App not releasing memory immediately
Hi Team, We have been working on one image processing app developed using react. In this app we are making the XMLHttpRequests to the server and storing the response in the cache which has around 200MB - 250MB of size. We are tracking the memory footprint using the Xcode instrument tool. While downloading and rendering the data in app the Xcode instrument shows the memory footprint around 800MB - 1000MB. We are assuming that garbage collection is not working as expected or some resources are not released after use and because of this we get this high memory footprint for 200MB - 250MB data. If the data is changed then we are removing the existing data from cache and storing the new data. But here, when we delete the data from cache, it does not release the memory immediately and takes some time of 3 seconds or more. In between this, the memory gets allocated to new data too and that increases the overall memory footprint of the app and in some cases the app is crashing. The maximum memory we have seen is average 1.5GB which varies with the device configuration. When we try the same activity on a safari browser where memory gets released immediately. If an app releases the initial acquired memory while loading new data we see very less app crashes. We need help to understand if there is a way to release the memory immediately to avoid the app crash. To reproduce this scenario, we have created a simple app which creates an array with size of 100MB and checks the memory footprint using the Xcode instrument tool. When we create an array of 100MB size, sometimes it shows the memory footprint peak of around 700MB-800MB and when we clear the array by assigning it with an empty array it releases the memory after 2-3 seconds. Created an array and then removed it and after removal of the array, created a new array of the same size immediately and again removed it. Because the memory is not released in time, if you repeat these steps a few times the app memory footprint will increase and that crashes the app.
0
1
305
Aug ’24