Image I/O

RSS for tag

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

Image I/O Documentation

Posts under Image I/O tag

61 Posts
Sort by:
Post not yet marked as solved
1 Replies
695 Views
I have been researching and enduring the most unbelievable attack you have ever heard of. You won't believe me. AT&T doesn't. Apple doesn't. They have not bothered to even take a look. I have multiple screen videos and screenshots that prove that when my phone was stolen, damaged, then returned, it was infected with a very resilient virus of some sort, so that it has been cloned and is duplicated on a MAC. Now the WiFi network I use is likely the jumping off point, but I am not familiar with this level of invasion. I have restored the phone but I have not deleted the E-Sim. And I always restored from a backup. Well once. I did not and still no change. I am not a neophyte, and while I have limited knowledge of the apple code, swift or Xcode or whatever, I do have some coding knowledge from other platforms. One thing I do know though is my iPhone. I bought the first one in 2007 and watched the keynote announcing the App Store on the first iPhone. I know when it is operating as it should. For instance, whenever I reset my google password which is often, or I just look through the google account at devices, this iPhone 14 {Plus running iOS 17 is always listed as a MAC OS X from another region. Sometimes I can see this phone on there as well but it is never the (device I am using). Also, I have screen videos of very strange errors, like certain options will be shut off. Like right now I cannot turn on voice assist. During the damage when it was stolen, the Face ID was damaged. Just now it suddenly got brighter and it does that often almost as often as the volume suddenly going up. My contacts are constantly deleted and that is not because of switching accounts. As this has been occurring four over 4 months now, I have tirelessly investigated every explanation for the errors. I know it is a mac connected to the same WiFi because occasionally the font will change in size and small part of text will be highlighted and it is much smaller than the display of the phone. Everytime I login to Apple ID the password has been changed and this is with 2FA on. Also I just checked yesterday to see, on the AT&T website, and my number in just one day has (5Text messages listed that I did not get. My roommates seem to know things about me I haven't told them. At&T sent me a bill for a different number without a phone connected to it. I use an ESim. I have endless more details and screenshots and I cannot seem to get a response from apple, but my belongings have been stolen, my identity stolen, and my sanity also taken away. You begin to question reality, but just going over my body of evidence is enough to show I have something going on. I want to report this to someone but I would like to maybe get some info on how I could be sure, what is happening? MY Crash reports show interesting stuff. I am actually going to check and make sure the imei numbers in those reports match the device. But please help . This is like super high tech invisible terrorizing spyware and it will be worse for the next person. I mean when I unlock my phone it is never opened to the app I closed it on. NEVER. Email johnmichaelpowers@yahoo.com
Posted Last updated
.
Post not yet marked as solved
0 Replies
528 Views
In iOS 17 beta3 and later versions, it has been observed that encoding using UIImagePNGRepresentation, manually using CGImageDestinationFinalize for encoding, or using the new UIImageHEICRepresentation, all result in color shifting issues for the corresponding images. The original data can be downloaded from https://mdn.alipayobjects.com/promo_creative/afts/img/A*RxJIQ60ntZMAAAAAAAAAAAAAAVR1AQ/original. Could you please help investigate the cause of this issue?
Posted Last updated
.
Post not yet marked as solved
9 Replies
986 Views
I'm trying to save metal textures in a lossless compressed format. I've tried png and tiff, but I run into the same problem: the pixel data changes after save and load when we have transparency. Here is the code I use to save a Tiff: import ImageIO import UIKit import Metal import MobileCoreServices extension MTLTexture { func saveAsLosslessTIFF(url: URL) throws { guard let context = CIContext() else { return } guard let colorSpace = CGColorSpace(name: CGColorSpace.linearSRGB) else { return } guard let ciImage = CIImage(mtlTexture: self, options: [.colorSpace : colorSpace]) else { return } guard let cgImage = context.createCGImage(ciImage, from: ciImage.extent) else { return } // create a dictionary with TIFF compression options let tiffCompression_LZW = 5 let options: [String: Any] = [ kCGImagePropertyTIFFCompression as String: tiffCompression_LZW, kCGImagePropertyDepth as String: depth, kCGImagePropertyPixelWidth as String: width, kCGImagePropertyPixelHeight as String: height, ] let fileDestination = CGImageDestinationCreateWithURL(url as CFURL, kUTTypeTIFF, 1, nil) guard let destination = fileDestination else { throw RuntimeError("Unable to create image destination.") } CGImageDestinationAddImage(destination, cgImage, options as CFDictionary) if !CGImageDestinationFinalize(destination) { throw RuntimeError("Unable to save image to destination.") } } } I can then load the texture like this: func loadTexture(url:URL) throws -> MTLTexture { let usage = MTLTextureUsage(rawValue: MTLTextureUsage.renderTarget.rawValue | MTLTextureUsage.shaderRead.rawValue | MTLTextureUsage.shaderWrite.rawValue) return try loader.newTexture(URL:url,options:[MTKTextureLoader.Option.textureUsage:usage.rawValue,MTKTextureLoader.Option.origin:MTKTextureLoader.Origin.flippedVertically.rawValue]) } After saving and then loading the texture again, I want to get back the exact same texture. And I do, if there is no transparency. Transparent pixels, however, are transformed in a way that I don't understand. Here is an example pixel: [120, 145, 195, 170] -> [144, 174, 234, 170] My first guess would be that something is trying to undo a pre-multiplied alpha that never happened. But the numbers don't seem to work out. For example, if that were the case I'd expect 120 to go to (120 * 255) / 170 = 180 , not 144. Any idea what I am doing wrong?
Posted Last updated
.
Post not yet marked as solved
1 Replies
555 Views
In my iOS app, I need to load and display lots of small images like icons and thumbnails. This was causing slow loading and high memory usage issues. I tried optimizing by encoding the images to Base64 strings and embedding them directly in code. Here's a Swift code snippet to demonstrate: let imageData = UIImage(named:"image.png")!.pngData()! let base64String = imageData.base64EncodedString() let imgBase64 = "data:image/png;base64,\(base64String)" let image = UIImage(data: Data(base64Encoded: imgBase64)!) This improved the app's performance - loading speed increased by 2x and memory usage decreased by 30%. Way better than loading individual image files! Curious to know if anyone else has tried Base64 image loading? Are there other optimization techniques you'd recommend? I'm interested to learn more approaches to smooth image loading in iOS apps. Btw, this blog post gave me the idea to try Base64 encoding for faster image loading. Recommend checking it out for more techniques! https://itoolkit.co/blog/2023/08/improve-page-speed-and-seo-with-base64-encoding-images/
Posted Last updated
.
Post not yet marked as solved
1 Replies
620 Views
I'm trying to create a sky mask on pictures taken from my iPhone. I've seen in the documentation that CoreImage support semantic segmentation for Sky among other type for person (skin, hair etc...) For now, I didn't found the proper workflow to use it. First, I watched https://developer.apple.com/videos/play/wwdc2019/225/ I understood that images must be captured with the segmentation with this kind of code: photoSettings.enabledSemanticSegmentationMatteTypes = self.photoOutput.availableSemanticSegmentationMatteTypes photoSettings.embedsSemanticSegmentationMattesInPhoto = true I capture the image on my iPhone, save it as HEIC format then later, I try to load the matte like that : let skyMatte = CIImage(contentsOf: imageURL, options: [.auxiliarySemanticSegmentationSkyMatte: true]) Unfortunately, self.photoOutput.availableSemanticSegmentationMatteTypes always give me a list of types for person only and never a types Sky. Anyway, the AVSemanticSegmentationMatte.MatteType is just [Hair, Skin, Teeth, Glasses] ... No Sky !!! So, How am I supposed to use semanticSegmentationSkyMatteImage ?!? Is there any simple workaround ?
Posted Last updated
.
Post not yet marked as solved
3 Replies
1.8k Views
I  am trying to save an image to the user's photo library using PHPhotoLibrary and set the image file name at the time of saving suing the code below. This is working the first time, but if I then try to save the same image again with a different file name, it saves with the same file name as before. Is there something I need to add to let the system know to save a new version of the image with a new file name? Thank you PHPhotoLibrary.shared().performChanges ({ let assetType:PHAssetResourceType = .photo let request:PHAssetCreationRequest = .forAsset() let createOptions:PHAssetResourceCreationOptions = PHAssetResourceCreationOptions() createOptions.originalFilename = "\(fileName)" request.addResource(with: assetType, data: image.jpegData(compressionQuality: 1)!, options: createOptions) }, completionHandler: { success, error in if success == true && error == nil { print("Success saving image") } else { print("Error saving image: \(error!.localizedDescription)") } })
Posted
by tomcoomer.
Last updated
.
Post not yet marked as solved
9 Replies
1.9k Views
I was wondering if anyone has same problem. When i plug the iphone to my windows laptop the folders in iphone showing a chinese word next to the folder name. Also images format having different type of word and when i copy them to the windows, it doesn't recognize them as images. I have already erase the iphone and when plug again, same issue is there. Please refer attached two pics. I'm running IOS 17 public beta.
Posted Last updated
.
Post not yet marked as solved
3 Replies
666 Views
I am trying to load an app icon from an icns file. I am using the following code: guard let url = NSWorkspace.shared.urlForApplication(withBundleIdentifier: "com.microsoft.VSCode") else { return nil } let icon = NSWorkspace.shared.icon(forFile: url.path) This seems to work very fine for all apps that I tested. All of them? No. Loading the icon for Visual Studio Code takes 4-5 seconds. Are there any other, faster methods? I also tried to use NSImage(contentsOfFile: url.path) which also takes very long. I have uploaded the icns file here: https://sascha-simon.com/Code.icns How can this behavior be explained?
Posted
by inexcitus.
Last updated
.
Post not yet marked as solved
0 Replies
1.2k Views
I'm using CoreGraphics and Image I/O in a MacOS command-line tool. My program works fine, but after the first drawing to a bitmap context there are messages output to the console like the following: 2022-12-20 16:33:47.824937-0500 RandomImageGenerator[4436:90170] Metal API Validation Enabled AVEBridge Info: AVEEncoder_CreateInstance: Received CreateInstance (from VT) AVEBridge Info: connectHandler: Device connected (0x000000010030b520)Assert - (remoteService != NULL) - f: /AppleInternal/Library/BuildRoots/43362d89-619c-11ed-a949-7ef33c48bc85/Library/Caches/com.apple.xbs/Sources/AppleAVEBridge/AppleAVEEncoder/AppleAVEEncoder.c l: 291 AVE XPC Error: could not find remote service Assert - (err == noErr) - f: /AppleInternal/Library/BuildRoots/43362d89-619c-11ed-a949-7ef33c48bc85/Library/Caches/com.apple.xbs/Sources/AppleAVEBridge/AppleAVEEncoder/AppleAVEEncoder.c l: 1961 AVE ERROR: XPC failed AVEBridge Info: stopUserClient: IOServiceClose was successful. AVEBridge Error: AVEEncoder_CreateInstance: returning err = -12908 These messages get in the way of my own console output. How do I stop these messages from being displayed? This post on StackOverflow (https://stackoverflow.com/questions/37800790/hide-strange-unwanted-xcode-logs) does not appear to be relevant to this issue.
Posted Last updated
.
Post not yet marked as solved
1 Replies
1.2k Views
Hello everyone, I'm facing an issue with my SwiftUI project, and I would appreciate some help in resolving it. The problem is that one of the images in my project is not visible when I use it in my code. Here are the details of the issue: I have for example two images, "AIOx2.png" and "AIOx3.png", both of which are placed in the "Assets.xcassets" folder of my Xcode project. When I use "AIOx3.png" in my SwiftUI code (e.g., replacing Image("AIOx2") with Image("AIOx3")), the image is visible on the preview canvas and simulator. However, when I use "AIOx2.png" in the same way, the image is not visible on the preview canvas or the simulator. I have verified that the file "AIOx2.png" is correctly named and is in the same location as "AIOx3.png" in the "Assets.xcassets" folder. There are no error messages or warnings related to the image in the Xcode console. I have tried several troubleshooting steps, such as cleaning and build, restarting Xcode, re-downloading and re-adding the image to the project, but the issue persists. Is there anything specific that I might be missing or any other suggestions for troubleshooting this problem? I would be grateful for any guidance or insights into resolving this issue. Thank you in advance for your help! Best regards, Adam
Posted
by adamfz.
Last updated
.
Post not yet marked as solved
0 Replies
792 Views
Previously art work used and porting a complex 3D mechanical Clock I am running into constant build errors using my previous art work .scn files I had some success converting my .usdz original to .scn file some convert but most just being in the art folder of the build environment cause this crash and are no longer compatible I use the same art work of gears and parts in UNITY build environment without any build issues most of my clocks have up to 35 different interacting parts These are replicas of classical clock mechanism Is any one else having problems with similar .scn files [?]
Posted Last updated
.
Post not yet marked as solved
0 Replies
731 Views
When using the heif10Representation and writeHEIF10Representation APIs of CIContext, the resulting image doesn’t contain an alpha channel. When using the heifRepresentation and writeHEIFRepresentation APIs, the alpha channel is properly preserved, i.e., the resulting HEIC will contain a urn:mpeg:hevc:2015:auxid:1 auxiliary image. This image is missing when exporting as HEIF10. Is this a bug or is this intentional? If I understand the spec correctly, HEIF10 should be able to support alpha via auxiliary image (like HEIF8).
Posted Last updated
.
Post not yet marked as solved
0 Replies
703 Views
I am getting 4 warnings compiling the current template of sceneKit game /Users/helmut/Documents/spaceTime/scntool:1:1 Could not find bundle inside /Library/Developer/CommandLineTools any idea why the bundle is not installed I did a new download twice now still stuck getting these warnings about bundles not installed or not found any solution to correct the download install so the base dependencies are present thank you
Posted Last updated
.
Post not yet marked as solved
0 Replies
777 Views
Hi, I have some SVG assets that are natively in 512x512 resolution. I want to use 20 of them in a Widget context where memory consumption must be kept low (due to 30MB Memory limit in extensions). As in that widget context, the images are display in small size (they are displayed in full size in the app) I would like to load a downsampled version of the images (let say 32x32). Is there any way to achieve that? (perhaps with configuration or traitCollection) I could resize them after having loading them full size but it will nevertheless create a memory peak consumption while resizing all the images... Thanks in advance for the help. PS: I really want to avoid to generate smaller preview images just for that purpose but if I can't find a better solution I could ask the app to generate thumbs for all images at first startup and use these thumbs in the widgets... Clement
Posted
by Clem23.
Last updated
.
Post not yet marked as solved
2 Replies
731 Views
Hi all, I got an error: 'Color' cannot be constructed because it has no accessible initializers. The error I get from the statement: .background(Color(uiColor: UIColor(red: 0.93, green: 0.93, blue: 0.94, alpha: 1.00))) I always use it but it's failed now. Is there anyone have the same issues? Please give me an advice of how I can fix it. Thanks
Posted
by Salmdo.
Last updated
.
Post not yet marked as solved
1 Replies
597 Views
I was trying to take an image of a car that includes the license plate. But later when I checked the numbers in the license plate is not clear and readable. When I did a zoom there are slanting lines in place. Is there any settings available to avoid?
Posted
by Ajikoikal.
Last updated
.
Post not yet marked as solved
0 Replies
614 Views
ImageSaver class: class ImageSaver: NSObject { var successHandler: (() -> Void)? var errorHandler: ((Error) -> Void)? func writeToPhotoAlbum(image: UIImage) { UIImageWriteToSavedPhotosAlbum(image, self, #selector(saveCompleted), nil) } @objc func saveCompleted(_ image: UIImage, didFinishSavingWithError error: Error?, contextInfo: UnsafeRawPointer) { if let error = error { errorHandler?(error) } else { successHandler?() } } } button action to trigger the download of a png file from URL: Button{ let imageSaver = ImageSaver() imageSaver.successHandler = { print("Success!") } imageSaver.errorHandler = { print("Oops: \($0.localizedDescription)") } let imageRequestUrl = URL(string: lastImageUrl)! // I'm sure that I can see the image url is valid and I can // downloaded it from Google chrome successfully print("imageRequestUrl:\(imageRequestUrl)") let req = URLRequest(url: imageRequestUrl) let task = URLSession.shared.dataTask(with: req) { d, res, err in if let data = d, let image = UIImage(data: data) { imageSaver.writeToPhotoAlbum(image: image) } } task.resume() } And this is the error: findWriterForTypeAndAlternateType:119: unsupported file format 'org.webmproject.webp' More info When I change the image URL to another one, like some other open-source png file, there's no error.... please help why it's so weird?
Posted
by RealLau.
Last updated
.
Post not yet marked as solved
1 Replies
1.2k Views
Environment Xcode 14 ios 16 Error [Unknown process name] CGImageCreate: invalid image byte order info for bitsPerPixel != 32 = 16384 And when I run my app in iphone, it can't show the image of result. It seems that there are some bugs when running in ios 16. How can I solve this problem?
Posted
by flygod.
Last updated
.
Post not yet marked as solved
0 Replies
556 Views
Example : android url : https://play.google.com/store/apps/details?id=com.moevd.android.user&referrer=t=u&c=Azhar Android getting this referrer from play store by google Analytics . how this possible for iOS ? like how can we get referrer from App Store ? how related google analytics to Apple Store? info given above.
Posted Last updated
.
Post not yet marked as solved
0 Replies
1.5k Views
In iOS 16, can not displaying PDF included gradients. PDF displayed normally if used Radial or Linear Gradient. Complex shape gradients are not displayed. The PDF is not displayed inside the iOS-application resources and when open file in iPhone use Files app normally. Attached an example with a regular Diamond gradient, which was created use Figma. iOS 15 displays the example file correctly. You can open file if change file format: Example.json rename to -> Example.pdf. P.S. I can't attached pdf or zip files. Example.json
Posted
by Tvorec.
Last updated
.