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

200 Posts

Post

Replies

Boosts

Views

Activity

Logo white background issue in iPhone dark theme Yahoo mail app
We are using PNG Transparent logo image for display in Dark and Light theme when sending a mail to the user. So, based on the user's screen settings, i.e. dark or light theme, background of the logo will be Black for Dark theme and White for Light theme.   But this is not working in the case of Yahoo mail app for iPhone dark theme. Yahoo mail app in iPhone for dark theme, by default, renders a white background color on CIBC logo image which is not looking good. Request you to kindly advise on the above. Please find screenshot of the issue attached.
2
1
2.1k
May ’23
SwiftUI ImagePicker Camera Issue
Hello! I'm unable to take pictures from my swiftui app using a simple image picker, the camera sheet comes up but when I take a picture and choose" use this picture", nothing happens, this is the error I keep getting: Attempted to change to mode Portrait with an unsupported device (BackAuto). Auto device for both positions unsupported, returning Auto device for same position anyway (BackAuto). Please does anyone have any advice on how I can fix this
1
3
2.8k
May ’23
Balancing User Experience and Privacy: Opt-in Image Storage
Hi everyone, I'm currently working on an app that allows users in the US and Canada to generate social media captions for their images using AI. The app has a feature where users can save the generated captions, and I'm considering whether or not to store the associated images on Firebase storage. My main goal is to allow users to refer back to their images when they view their saved captions. However, I'm also concerned about potential legal issues that might arise from storing user-generated images, especially since the app is not designed for sharing these images with other users. To give users more control over their data, I'm thinking about adding a toggle in the settings menu that allows them to choose if their images should be stored or not. I believe this could improve transparency and user satisfaction, but I'm unsure if this approach would help me avoid legal issues related to data storage and privacy for US and Canadian users. I would appreciate any insights or suggestions from the community, especially if you have experience with similar features or legal concerns in the context of US and Canadian data protection regulations. Also, I'd be grateful for recommendations on where to seek more information or consult with professionals in this area. Thanks in advance for your help!
0
0
732
May ’23
Crashed: com.apple.main-thread EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x000000012bfb65a0
We got Crashed: com.apple.main-thread 0 libsystem_platform.dylib 0x1254 platform_memmove + 420 1 CoreMedia 0xaeffc FigDataByteStreamRead + 120 2 CMPhoto 0x1c824 CMPhotoImageContainerFormatDetectFromBytestream + 368 3 CMPhoto 0x6378 CMPhotoDecompressionContainerCreate + 432 4 ImageIO 0x1f03c AppleJPEGReadPlugin::copyIOSurface(InfoRec*, CGImageProvider*, __CFDictionary const*) + 356 5 ImageIO 0x22964 AppleJPEGReadPlugin::createImageBlockSetWithHardwareDecode(InfoRec*, CGImageProvider*, CGSize, __CFDictionary const*) + 232 6 ImageIO 0x3e0c8 AppleJPEGReadPlugin::copyImageBlockSet(InfoRec*, CGImageProvider*, CGRect, CGSize, __CFDictionary const*) + 1608 7 ImageIO 0x1a774 IIO_Reader::CopyImageBlockSetProc(void*, CGImageProvider*, CGRect, CGSize, __CFDictionary const*) + 280 8 ImageIO 0x16224 IIOImageProviderInfo::copyImageBlockSetWithOptions(CGImageProvider*, CGRect, CGSize, __CFDictionary const*) + 744 9 ImageIO 0x1e2fc IIOImageProviderInfo::CopyImageBlockSetWithOptions(void*, CGImageProvider*, CGRect, CGSize, __CFDictionary const*) + 844 10 CoreGraphics 0x42694 imageProvider_retain_data + 92 11 CoreGraphics 0x60428 CGDataProviderRetainData + 80 12 CoreGraphics 0x7d0b0 provider_for_destination_retain_data + 28 13 CoreGraphics 0x60428 CGDataProviderRetainData + 80 14 CoreGraphics 0x3f3f0 CGAccessSessionCreate + 108 15 CoreGraphics 0xc0e4 img_data_lock + 2404 16 CoreGraphics 0x513ec CGSImageDataLock + 1328 17 CoreGraphics 0x2412c ripc_AcquireRIPImageData + 712 18 CoreGraphics 0x41864 ripc_DrawImage + 824 19 CoreGraphics 0x181b8 CGContextDrawImageWithOptions + 1120 20 UIKitCore 0x1b5db0 -[UIImage drawInRect:blendMode:alpha:] + 980 21 ELStickMeNotes 0x6bce4 specialized static ThemeSV.write(image:) + 111 (UtilMethods.swift:111) 22 ELStickMeNotes 0xd06c0 closure #1 in MyNotesVC.changeBackground() + 4344874688 23 ELStickMeNotes 0x6b364 closure #1 in closure #1 in ThemeSV.collectionView(:didSelectItemAt:) + 4344460132 24 ELStickMeNotes 0x168f24 thunk for @escaping @callee_guaranteed () -> () + 4345499428 (:4345499428) 25 libdispatch.dylib 0x2320 _dispatch_call_block_and_release + 32 26 libdispatch.dylib 0x3eac _dispatch_client_callout + 20 27 libdispatch.dylib 0x126a4 _dispatch_main_queue_drain + 928 28 libdispatch.dylib 0x122f4 _dispatch_main_queue_callback_4CF + 44 29 CoreFoundation 0x98d18 CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE + 16 30 CoreFoundation 0x7a650 __CFRunLoopRun + 1992 31 CoreFoundation 0x7f4dc CFRunLoopRunSpecific + 612 32 GraphicsServices 0x135c GSEventRunModal + 164 33 UIKitCore 0x39d37c -[UIApplication _run] + 888 34 UIKitCore 0x39cfe0 UIApplicationMain + 340 35 ELStickMeNotes 0x5b10 main + 20 (AppDelegate.swift:20) 36 ??? 0x1d6accdec (Missing) This Crash rarely occurs in iPhone 13 Pro Max iOS 16.4.1 The code is below. func resizeImage(withImage image:UIImage)-> UIImage? { let height = image.size.height let width = image.size.width UIGraphicsBeginImageContext(CGSize(width: width, height: height)) image.draw(in: CGRect(origin: CGPoint.zero, size: CGSize(width: width, height: height))) let image = UIGraphicsGetImageFromCurrentImageContext() UIGraphicsEndImageContext() return image }
0
0
852
Apr ’23
MTP (Media Transfer Protocol) support on iOS
Now that ImageCaptureCore framework is supported on iOS 13+, I was trying to write an application for browsing media files on devices connected via USB. The external device is connected to the iPhone via the "Lightning to USB 3 Camera Adapter" - https://www.apple.com/shop/product/MK0W2AM/A/lightning-to-usb-3-camera-adapter. The iOS application I'm writing is based on SimpleCameraBrowser - https://developer.apple.com/library/archive/samplecode/SimpleCameraBrowser/Introduction/Intro.html @interface AppDelegate () <ICDeviceBrowserDelegate, ICDeviceDelegate> @property (nonatomic, strong) ICDeviceBrowser *deviceBrowser; @property (nonatomic, strong) ICCameraDevice *camera; @end @implementation AppDelegate (void)deviceBrowser:(nonnull ICDeviceBrowser *)browser didAddDevice:(nonnull ICDevice *)device moreComing:(BOOL)moreComing {     NSLog( @"deviceBrowser:didAddDevice:moreComing: \n%@\n", device ); //    if (device.type & ICDeviceTypeCamera)     {         device.delegate = self; &#9;&#9;&#9;  self.camera = (ICCameraDevice *)device;         self.camera.delegate = self;         [self.camera requestOpenSession];     } } (void)device:(nonnull ICDevice *)device didOpenSessionWithError:(NSError * _Nullable)error {     NSLog( @"device:didOpenSessionWithError:error: \n%@\n", error );    } (void)deviceDidBecomeReady:(ICDevice*)device {     ICCameraDevice *camera = (ICCameraDevice *)device;     NSLog(@"%@, %@", device, camera.mediaFiles); } (void)deviceDidBecomeReadyWithCompleteContentCatalog:(ICCameraDevice*) device { &#9; NSLog(@"deviceDidBecomeReadyWithCompleteContentCatalog: %@", device.mediaFiles); } (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {     // Override point for customization after application launch.     self.deviceBrowser = [[ICDeviceBrowser alloc] init];     self.deviceBrowser.delegate = self;     [self.deviceBrowser start];          return YES; } What I'm seeing is that although the camera is found and successfully open a session, when receiving the callback deviceDidBecomeReady, the property mediaFiles is an empty array and never receive the call deviceDidBecomeReadyWithCompleteContentCatalog. Is ImageCaptureCore framework supposed to work on iOS? Does it work only on iPads and not on iPhones?
1
0
4.7k
Apr ’23
Cannot download or show image from URL with AppIntentsExtension
I'm working on App Shortcuts function with AppIntentsExtension which is recommended in WWDC22. But I'm struggled to download or show image after shortcut is executed. Here are main functions: func perform() async throws -> some IntentResult & ShowsSnippetView & ReturnsValue<URL> { let requestURL = URL(string: "https://cdn.leonardo.ai/users/3e2e4dd4-8b59-4eac-b8c1-e6a89d88da2c/generations/1db4905a-4593-4f49-9d9f-1179221c0ee3/Leonardo_Signature_A_pretty_animation_girl_3.jpg")! let result = FileDownloader.loadFileSync(url: requestURL) // BTW I don't see any log [Full.txt](https://developer.apple.com/forums/content/attachment/e72637a4-7c4e-4545-b66a-ec0a1bc232ca) in Xcode Consle print("Generate image finished") // Not work with or without PictureView // Also tried only return result URL, not work either return .result(value:result, view: PictureView(url: requestURL)) } struct PictureView: View { var url: URL var body: some View { ZStack{ // Cannot show nothing AsyncImage(url: url) // This shows Image(systemName: "photo.on.rectangle.angled") .symbolRenderingMode(.monochrome) .resizable() .scaledToFit() .frame(minWidth: 50, minHeight: 50) } } } Simply saying, I want to just show a image from url or download it so that I can check it out in Photos, using App Intents Extension.
1
0
870
Apr ’23
Problem appending attribute using AppleEXR
This is on macOS 13.2.1, M1 Max. I'm having an issue appending an attribute using AppleEXR. If I don't append the attribute (i.e. by commenting the code), the file appears to be valid. However when I add the attribute I can no longer load the image, and the opensource OpenEXR lib throws an exception about an attribute name longer than 255 chars. The lines in question are: const int32_t val = 1; const char *name = "acesImageContainerFlag"; const char *type = "int"; auto err = axr_part_append_attribute(part, name, type, sizeof val, reinterpret_cast<const uint8_t *>(&val), 0, nullptr); if (err != axr_error_success) { auto errStr = axr_error_get_name(err); NSLog(@"Failed to set acesImageContainerFlag: %s", errStr); } The err variable is always axr_error_success. Debugging into the opensource OpenEXR library when attempting to load the file, it seems like the attribute name and attribute type aren't being null terminated. I can append the chromaticities attribute successfully using axr_part_set_chromaticities. The structure of my code is as follows: axr_encoder_create axr_encoder_append_part /*axr_part_append_attribute*/ axr_part_set_chromaticities axr_part_append_channels axr_encoder_compress
0
0
666
Mar ’23
Converting UIImage to jpegData - [Metal] 9072 by 12198 iosurface is too large for GPU
Hi, I'm trying to convert images picked from the users camera roll into jpegData for me to upload to a server. I'm doing the following to covert to Data: let imageData: Data? = uiImage.jpegData(compressionQuality: 0) This works fine when converting screenshots. But when I attempt to convert an image taken using the device's camera. It gives me the following error: [Metal] 9072 by 12198 iosurface is too large for GPU It still converts it into data, but the data then just contains a blank image. Not the selected image. I'm at a loss with where to go with this one, I've tried converting HEIC preloaded onto the device's bundle and it works fine. But when using ones selected from the camera roll, I get the stated error. Any help would be appreciated. This is the sample code I'm using to test the issue. (I'm aware it's quite pointless in this form) func convertImage(image: Image?) -> Image? { //1 let key = "\(String.random(length: 15))" let uiImage: UIImage = image.asUIImage() let imageData: Data? = uiImage.jpegData(compressionQuality: 0) guard let imageData = imageData else { return nil } let encodedImage = imageData.base64EncodedString() let fileManager = FileManager.default let documentsPath = fileManager.urls(for: .documentDirectory, in: .userDomainMask).first let localImageUrl = (documentsPath?.appendingPathComponent(key)) guard let localImageUrl = localImageUrl else { return nil } try! encodedImage.write(to: localImageUrl, atomically: true, encoding: String.Encoding.utf8) guard let fileContents = try? String(contentsOf: localImageUrl) else { return nil } let dataDecoded : Data = Data(base64Encoded: fileContents, options: .ignoreUnknownCharacters)! let decodedimage = UIImage(data: dataDecoded) return (Image(uiImage: decodedimage ?? UIImage(named: "placeholder")!)) } import SwiftUI struct UploadTesting: View { @ObservedObject var crViewModel = ChatroomsViewModel() @State var showImagePicker = false @State var selectedImage: Image? = nil @State var convertedImage: Image? var body: some View { VStack { Button("Select") { showImagePicker.toggle() } selectedImage?.resizable().scaledToFit().frame(width: 300, height: 300) Button("Convert") { convertedImage = crViewModel.convertImage(image: selectedImage) } convertedImage?.resizable().scaledToFit().frame(width: 200, height: 200).background(Color.red) } .sheet(isPresented: $showImagePicker) { ImagePicker(image: $selectedImage) } } } Video of issue: https://streamable.com/h0uqly
5
1
5.8k
Mar ’23
Need a (simple) algorithm to tell if 2 images differ
I have a need to tell if 2 images are different by unimportant details. For example, one image is only slightly different than another because: *) It is a little stretched *) or it has 99% portion of another (only missing some pixels on borders) I wonder if there is an efficient algorithm to achieve my goal. Any suggestions are welcome.
3
0
2.4k
Mar ’23
Firebase Storage not uploading/downloading correctly
I am trying to publish and download images from firebase storage. I publish an Image, and then try to fetch it, which works, but when I try to replace that same image by another one, and then fetch that new image, it still shows me the old image, even though when I look in the database, it shows the new Image and nothing else. There are no errors. This is how I am fetching my image. let storageRef = Storage.storage().reference() let ref = storageRef.child("Profiles/\(UserModel.docId).jpeg")          let placeHolderImage = UIImage(systemName: "person.circle.fill")    profileImage.sd_setImage(with: ref, placeholderImage: placeHolderImage) This is how I am uploading my images let storageRef = Storage.storage().reference() let ref = storageRef.child("Profiles/\(UserModel.docId).jpeg")       let metaData = StorageMetadata() metaData.contentType = "image/jpeg" ref.putData(ImageData, metadata: metaData)
1
0
830
Mar ’23
Help making image background transparent in iMessage MessageExtension
I'm working on a MessageExtension app and trying to send an images with a transparent background through imessage. However when I add the image to the message, the image loses its background transparency and is filled in with a solid white. is there a way to mitigate this? For some more context, the user is picking the image from a CollectionView full of cells that contain a UIImageView. I can see in the CollectionView that the images have transparent backgrounds, and also when I run the program with a breakpoint and view the active variables the image has a transparent background. So I believe it has something to do when adding the image to a message. this is my code for adding the image to a message: guard let conversation = activeConversation else{ print("conversation failed") return } let layout = MSMessageTemplateLayout() layout.image = image //image is a UIImage let message = MSMessage() message.layout = layout conversation.insert(message) {error in if let error = error{ print("error sending message: \(String(describing: error))") } }
0
0
627
Feb ’23
ios, swift, image metadata, XMP, DJI Drones
I'm writing an iOS Swift app to fetch metadata from DJI drone images. I'm trying to access the Xmp.drone-dji.X metadata. The iOS/Swift CGImageSource and CGImageMetadata libraries/classes get almost all of the metadata out of the image but not the Xmp.drone-dji. When I get a list of tags, those tag/values are not listed. I know the tags/data are in the images because I've examined the images using exif, exiv2, etc. Any suggestions? Here is the code I'm using so far: result.itemProvider.loadDataRepresentation(forTypeIdentifier: UTType.image.identifier) { data, err in if let data = data { let src = CGImageSourceCreateWithData(data as CFData,nil)! let md = CGImageSourceCopyPropertiesAtIndex(src,0,nil) as! NSDictionary let md2 = CGImageSourceCopyMetadataAtIndex(src,0,nil) }
1
0
1.5k
Feb ’23
CGImageCreate() returns nil.
CGFloat width = any value;  CGFloat height = any value; CGDataProviderRef dataProviderRef = dataProviderRef = CGDataProviderCreateWithData(NULL, data, width * height * 2, nil); CGBitmapInfo bitmapInfo = kCGBitmapByteOrderMask | kCGImageAlphaNoneSkipLast; CGImageRef imageResult = CGImageCreate(width, height, 8, 16, width * 2, CGColorSpaceCreateDeviceGray(), bitmapInfo, dataProviderRef, NULL, 0, kCGRenderingIntentDefault); imageResult is nil. Please tell me an alternative method.
1
0
838
Feb ’23
The problem that different color tone of heif file on Ventura 13.2
Hi ! I'm testing my HEIF image files on Ventura 13.2 and I found something about different color-tone on Finder's Gallery. Shortly I explain it, Gallery in Finder app shows a HEIF image shows more brighter than Preview app. It did not happen on Ventura 13.1, just happen in 13.2. In order to explain more detail, I attached PPT file and image files. PPT: https://docs.google.com/presentation/d/1743G7KcSGChSFVvmCF0JR-EsBeXkJtLAGpmu6lkgMHU/edit?usp=share_link Image: https://drive.google.com/file/d/1ImfCEWuOhGOLpwsgc5KwRVFTCtVAiZtz/view?usp=share_link So, hopefully, I'm expecting you guys to check this problem and answer this post! Eventually, I hope you fix up this issue that I addressed in this post. Thanks. Seunghoon Baek.
1
0
690
Feb ’23
CSV to MultiArray generates grey image
I have a csv file with values ranges between 0-1. When converted this csv values to MLMultiArray and then to UIImage it shows grey image. But the image is actually coloured. So is there any step missing or do I have to perform any more action to get this image to be coloured. Sample csv values - [0.556862745 0.62745098 0.811764706]
Replies
0
Boosts
0
Views
717
Activity
May ’23
Logo white background issue in iPhone dark theme Yahoo mail app
We are using PNG Transparent logo image for display in Dark and Light theme when sending a mail to the user. So, based on the user's screen settings, i.e. dark or light theme, background of the logo will be Black for Dark theme and White for Light theme.   But this is not working in the case of Yahoo mail app for iPhone dark theme. Yahoo mail app in iPhone for dark theme, by default, renders a white background color on CIBC logo image which is not looking good. Request you to kindly advise on the above. Please find screenshot of the issue attached.
Replies
2
Boosts
1
Views
2.1k
Activity
May ’23
SwiftUI ImagePicker Camera Issue
Hello! I'm unable to take pictures from my swiftui app using a simple image picker, the camera sheet comes up but when I take a picture and choose" use this picture", nothing happens, this is the error I keep getting: Attempted to change to mode Portrait with an unsupported device (BackAuto). Auto device for both positions unsupported, returning Auto device for same position anyway (BackAuto). Please does anyone have any advice on how I can fix this
Replies
1
Boosts
3
Views
2.8k
Activity
May ’23
Balancing User Experience and Privacy: Opt-in Image Storage
Hi everyone, I'm currently working on an app that allows users in the US and Canada to generate social media captions for their images using AI. The app has a feature where users can save the generated captions, and I'm considering whether or not to store the associated images on Firebase storage. My main goal is to allow users to refer back to their images when they view their saved captions. However, I'm also concerned about potential legal issues that might arise from storing user-generated images, especially since the app is not designed for sharing these images with other users. To give users more control over their data, I'm thinking about adding a toggle in the settings menu that allows them to choose if their images should be stored or not. I believe this could improve transparency and user satisfaction, but I'm unsure if this approach would help me avoid legal issues related to data storage and privacy for US and Canadian users. I would appreciate any insights or suggestions from the community, especially if you have experience with similar features or legal concerns in the context of US and Canadian data protection regulations. Also, I'd be grateful for recommendations on where to seek more information or consult with professionals in this area. Thanks in advance for your help!
Replies
0
Boosts
0
Views
732
Activity
May ’23
Crashed: com.apple.main-thread EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x000000012bfb65a0
We got Crashed: com.apple.main-thread 0 libsystem_platform.dylib 0x1254 platform_memmove + 420 1 CoreMedia 0xaeffc FigDataByteStreamRead + 120 2 CMPhoto 0x1c824 CMPhotoImageContainerFormatDetectFromBytestream + 368 3 CMPhoto 0x6378 CMPhotoDecompressionContainerCreate + 432 4 ImageIO 0x1f03c AppleJPEGReadPlugin::copyIOSurface(InfoRec*, CGImageProvider*, __CFDictionary const*) + 356 5 ImageIO 0x22964 AppleJPEGReadPlugin::createImageBlockSetWithHardwareDecode(InfoRec*, CGImageProvider*, CGSize, __CFDictionary const*) + 232 6 ImageIO 0x3e0c8 AppleJPEGReadPlugin::copyImageBlockSet(InfoRec*, CGImageProvider*, CGRect, CGSize, __CFDictionary const*) + 1608 7 ImageIO 0x1a774 IIO_Reader::CopyImageBlockSetProc(void*, CGImageProvider*, CGRect, CGSize, __CFDictionary const*) + 280 8 ImageIO 0x16224 IIOImageProviderInfo::copyImageBlockSetWithOptions(CGImageProvider*, CGRect, CGSize, __CFDictionary const*) + 744 9 ImageIO 0x1e2fc IIOImageProviderInfo::CopyImageBlockSetWithOptions(void*, CGImageProvider*, CGRect, CGSize, __CFDictionary const*) + 844 10 CoreGraphics 0x42694 imageProvider_retain_data + 92 11 CoreGraphics 0x60428 CGDataProviderRetainData + 80 12 CoreGraphics 0x7d0b0 provider_for_destination_retain_data + 28 13 CoreGraphics 0x60428 CGDataProviderRetainData + 80 14 CoreGraphics 0x3f3f0 CGAccessSessionCreate + 108 15 CoreGraphics 0xc0e4 img_data_lock + 2404 16 CoreGraphics 0x513ec CGSImageDataLock + 1328 17 CoreGraphics 0x2412c ripc_AcquireRIPImageData + 712 18 CoreGraphics 0x41864 ripc_DrawImage + 824 19 CoreGraphics 0x181b8 CGContextDrawImageWithOptions + 1120 20 UIKitCore 0x1b5db0 -[UIImage drawInRect:blendMode:alpha:] + 980 21 ELStickMeNotes 0x6bce4 specialized static ThemeSV.write(image:) + 111 (UtilMethods.swift:111) 22 ELStickMeNotes 0xd06c0 closure #1 in MyNotesVC.changeBackground() + 4344874688 23 ELStickMeNotes 0x6b364 closure #1 in closure #1 in ThemeSV.collectionView(:didSelectItemAt:) + 4344460132 24 ELStickMeNotes 0x168f24 thunk for @escaping @callee_guaranteed () -> () + 4345499428 (:4345499428) 25 libdispatch.dylib 0x2320 _dispatch_call_block_and_release + 32 26 libdispatch.dylib 0x3eac _dispatch_client_callout + 20 27 libdispatch.dylib 0x126a4 _dispatch_main_queue_drain + 928 28 libdispatch.dylib 0x122f4 _dispatch_main_queue_callback_4CF + 44 29 CoreFoundation 0x98d18 CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE + 16 30 CoreFoundation 0x7a650 __CFRunLoopRun + 1992 31 CoreFoundation 0x7f4dc CFRunLoopRunSpecific + 612 32 GraphicsServices 0x135c GSEventRunModal + 164 33 UIKitCore 0x39d37c -[UIApplication _run] + 888 34 UIKitCore 0x39cfe0 UIApplicationMain + 340 35 ELStickMeNotes 0x5b10 main + 20 (AppDelegate.swift:20) 36 ??? 0x1d6accdec (Missing) This Crash rarely occurs in iPhone 13 Pro Max iOS 16.4.1 The code is below. func resizeImage(withImage image:UIImage)-> UIImage? { let height = image.size.height let width = image.size.width UIGraphicsBeginImageContext(CGSize(width: width, height: height)) image.draw(in: CGRect(origin: CGPoint.zero, size: CGSize(width: width, height: height))) let image = UIGraphicsGetImageFromCurrentImageContext() UIGraphicsEndImageContext() return image }
Replies
0
Boosts
0
Views
852
Activity
Apr ’23
MTP (Media Transfer Protocol) support on iOS
Now that ImageCaptureCore framework is supported on iOS 13+, I was trying to write an application for browsing media files on devices connected via USB. The external device is connected to the iPhone via the "Lightning to USB 3 Camera Adapter" - https://www.apple.com/shop/product/MK0W2AM/A/lightning-to-usb-3-camera-adapter. The iOS application I'm writing is based on SimpleCameraBrowser - https://developer.apple.com/library/archive/samplecode/SimpleCameraBrowser/Introduction/Intro.html @interface AppDelegate () <ICDeviceBrowserDelegate, ICDeviceDelegate> @property (nonatomic, strong) ICDeviceBrowser *deviceBrowser; @property (nonatomic, strong) ICCameraDevice *camera; @end @implementation AppDelegate (void)deviceBrowser:(nonnull ICDeviceBrowser *)browser didAddDevice:(nonnull ICDevice *)device moreComing:(BOOL)moreComing {     NSLog( @"deviceBrowser:didAddDevice:moreComing: \n%@\n", device ); //    if (device.type & ICDeviceTypeCamera)     {         device.delegate = self; &#9;&#9;&#9;  self.camera = (ICCameraDevice *)device;         self.camera.delegate = self;         [self.camera requestOpenSession];     } } (void)device:(nonnull ICDevice *)device didOpenSessionWithError:(NSError * _Nullable)error {     NSLog( @"device:didOpenSessionWithError:error: \n%@\n", error );    } (void)deviceDidBecomeReady:(ICDevice*)device {     ICCameraDevice *camera = (ICCameraDevice *)device;     NSLog(@"%@, %@", device, camera.mediaFiles); } (void)deviceDidBecomeReadyWithCompleteContentCatalog:(ICCameraDevice*) device { &#9; NSLog(@"deviceDidBecomeReadyWithCompleteContentCatalog: %@", device.mediaFiles); } (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {     // Override point for customization after application launch.     self.deviceBrowser = [[ICDeviceBrowser alloc] init];     self.deviceBrowser.delegate = self;     [self.deviceBrowser start];          return YES; } What I'm seeing is that although the camera is found and successfully open a session, when receiving the callback deviceDidBecomeReady, the property mediaFiles is an empty array and never receive the call deviceDidBecomeReadyWithCompleteContentCatalog. Is ImageCaptureCore framework supposed to work on iOS? Does it work only on iPads and not on iPhones?
Replies
1
Boosts
0
Views
4.7k
Activity
Apr ’23
Can I use the images generated by Midjourney in my project?
I'm not sure if it's allowed to use. https://docs.midjourney.com/docs/terms-of-service
Replies
1
Boosts
0
Views
1.7k
Activity
Apr ’23
Cannot download or show image from URL with AppIntentsExtension
I'm working on App Shortcuts function with AppIntentsExtension which is recommended in WWDC22. But I'm struggled to download or show image after shortcut is executed. Here are main functions: func perform() async throws -> some IntentResult & ShowsSnippetView & ReturnsValue<URL> { let requestURL = URL(string: "https://cdn.leonardo.ai/users/3e2e4dd4-8b59-4eac-b8c1-e6a89d88da2c/generations/1db4905a-4593-4f49-9d9f-1179221c0ee3/Leonardo_Signature_A_pretty_animation_girl_3.jpg")! let result = FileDownloader.loadFileSync(url: requestURL) // BTW I don't see any log [Full.txt](https://developer.apple.com/forums/content/attachment/e72637a4-7c4e-4545-b66a-ec0a1bc232ca) in Xcode Consle print("Generate image finished") // Not work with or without PictureView // Also tried only return result URL, not work either return .result(value:result, view: PictureView(url: requestURL)) } struct PictureView: View { var url: URL var body: some View { ZStack{ // Cannot show nothing AsyncImage(url: url) // This shows Image(systemName: "photo.on.rectangle.angled") .symbolRenderingMode(.monochrome) .resizable() .scaledToFit() .frame(minWidth: 50, minHeight: 50) } } } Simply saying, I want to just show a image from url or download it so that I can check it out in Photos, using App Intents Extension.
Replies
1
Boosts
0
Views
870
Activity
Apr ’23
Problem appending attribute using AppleEXR
This is on macOS 13.2.1, M1 Max. I'm having an issue appending an attribute using AppleEXR. If I don't append the attribute (i.e. by commenting the code), the file appears to be valid. However when I add the attribute I can no longer load the image, and the opensource OpenEXR lib throws an exception about an attribute name longer than 255 chars. The lines in question are: const int32_t val = 1; const char *name = "acesImageContainerFlag"; const char *type = "int"; auto err = axr_part_append_attribute(part, name, type, sizeof val, reinterpret_cast<const uint8_t *>(&val), 0, nullptr); if (err != axr_error_success) { auto errStr = axr_error_get_name(err); NSLog(@"Failed to set acesImageContainerFlag: %s", errStr); } The err variable is always axr_error_success. Debugging into the opensource OpenEXR library when attempting to load the file, it seems like the attribute name and attribute type aren't being null terminated. I can append the chromaticities attribute successfully using axr_part_set_chromaticities. The structure of my code is as follows: axr_encoder_create axr_encoder_append_part /*axr_part_append_attribute*/ axr_part_set_chromaticities axr_part_append_channels axr_encoder_compress
Replies
0
Boosts
0
Views
666
Activity
Mar ’23
Converting UIImage to jpegData - [Metal] 9072 by 12198 iosurface is too large for GPU
Hi, I'm trying to convert images picked from the users camera roll into jpegData for me to upload to a server. I'm doing the following to covert to Data: let imageData: Data? = uiImage.jpegData(compressionQuality: 0) This works fine when converting screenshots. But when I attempt to convert an image taken using the device's camera. It gives me the following error: [Metal] 9072 by 12198 iosurface is too large for GPU It still converts it into data, but the data then just contains a blank image. Not the selected image. I'm at a loss with where to go with this one, I've tried converting HEIC preloaded onto the device's bundle and it works fine. But when using ones selected from the camera roll, I get the stated error. Any help would be appreciated. This is the sample code I'm using to test the issue. (I'm aware it's quite pointless in this form) func convertImage(image: Image?) -> Image? { //1 let key = "\(String.random(length: 15))" let uiImage: UIImage = image.asUIImage() let imageData: Data? = uiImage.jpegData(compressionQuality: 0) guard let imageData = imageData else { return nil } let encodedImage = imageData.base64EncodedString() let fileManager = FileManager.default let documentsPath = fileManager.urls(for: .documentDirectory, in: .userDomainMask).first let localImageUrl = (documentsPath?.appendingPathComponent(key)) guard let localImageUrl = localImageUrl else { return nil } try! encodedImage.write(to: localImageUrl, atomically: true, encoding: String.Encoding.utf8) guard let fileContents = try? String(contentsOf: localImageUrl) else { return nil } let dataDecoded : Data = Data(base64Encoded: fileContents, options: .ignoreUnknownCharacters)! let decodedimage = UIImage(data: dataDecoded) return (Image(uiImage: decodedimage ?? UIImage(named: "placeholder")!)) } import SwiftUI struct UploadTesting: View { @ObservedObject var crViewModel = ChatroomsViewModel() @State var showImagePicker = false @State var selectedImage: Image? = nil @State var convertedImage: Image? var body: some View { VStack { Button("Select") { showImagePicker.toggle() } selectedImage?.resizable().scaledToFit().frame(width: 300, height: 300) Button("Convert") { convertedImage = crViewModel.convertImage(image: selectedImage) } convertedImage?.resizable().scaledToFit().frame(width: 200, height: 200).background(Color.red) } .sheet(isPresented: $showImagePicker) { ImagePicker(image: $selectedImage) } } } Video of issue: https://streamable.com/h0uqly
Replies
5
Boosts
1
Views
5.8k
Activity
Mar ’23
Need a (simple) algorithm to tell if 2 images differ
I have a need to tell if 2 images are different by unimportant details. For example, one image is only slightly different than another because: *) It is a little stretched *) or it has 99% portion of another (only missing some pixels on borders) I wonder if there is an efficient algorithm to achieve my goal. Any suggestions are welcome.
Replies
3
Boosts
0
Views
2.4k
Activity
Mar ’23
How create thumbnail from NSImage?
I did searches on the Internet but could not find a definitive answer. The best thing I get is CGImageSourceCreateThumbnailAtIndex API function. But I don't know how create CGImageSource out of an NSImage object. Thanks for any suggestions.
Replies
0
Boosts
0
Views
750
Activity
Mar ’23
Firebase Storage not uploading/downloading correctly
I am trying to publish and download images from firebase storage. I publish an Image, and then try to fetch it, which works, but when I try to replace that same image by another one, and then fetch that new image, it still shows me the old image, even though when I look in the database, it shows the new Image and nothing else. There are no errors. This is how I am fetching my image. let storageRef = Storage.storage().reference() let ref = storageRef.child("Profiles/\(UserModel.docId).jpeg")          let placeHolderImage = UIImage(systemName: "person.circle.fill")    profileImage.sd_setImage(with: ref, placeholderImage: placeHolderImage) This is how I am uploading my images let storageRef = Storage.storage().reference() let ref = storageRef.child("Profiles/\(UserModel.docId).jpeg")       let metaData = StorageMetadata() metaData.contentType = "image/jpeg" ref.putData(ImageData, metadata: metaData)
Replies
1
Boosts
0
Views
830
Activity
Mar ’23
Api to upload app screenshots and metadata
Do we have any api to upload app screenshots and metadata or create experiments with Screenshots and metadata for appstore connect ?
Replies
1
Boosts
1
Views
2.1k
Activity
Mar ’23
VTDecompressionSessionRemoteClient_TileCreate hangs on iOS
Our users encounter the problem of stuck browsing pictures in the process of using. Please help to see what the problem is. Thank you. (Attached is the crash log)
Replies
2
Boosts
0
Views
1.3k
Activity
Feb ’23
Live Photo WallPaper
when u use a Live photo at wallpaper, u cant see like a live photo , is just a normal photo … i think im doing something bad , but if this is true.. pls bring it back again
Replies
0
Boosts
0
Views
796
Activity
Feb ’23
Help making image background transparent in iMessage MessageExtension
I'm working on a MessageExtension app and trying to send an images with a transparent background through imessage. However when I add the image to the message, the image loses its background transparency and is filled in with a solid white. is there a way to mitigate this? For some more context, the user is picking the image from a CollectionView full of cells that contain a UIImageView. I can see in the CollectionView that the images have transparent backgrounds, and also when I run the program with a breakpoint and view the active variables the image has a transparent background. So I believe it has something to do when adding the image to a message. this is my code for adding the image to a message: guard let conversation = activeConversation else{ print("conversation failed") return } let layout = MSMessageTemplateLayout() layout.image = image //image is a UIImage let message = MSMessage() message.layout = layout conversation.insert(message) {error in if let error = error{ print("error sending message: \(String(describing: error))") } }
Replies
0
Boosts
0
Views
627
Activity
Feb ’23
ios, swift, image metadata, XMP, DJI Drones
I'm writing an iOS Swift app to fetch metadata from DJI drone images. I'm trying to access the Xmp.drone-dji.X metadata. The iOS/Swift CGImageSource and CGImageMetadata libraries/classes get almost all of the metadata out of the image but not the Xmp.drone-dji. When I get a list of tags, those tag/values are not listed. I know the tags/data are in the images because I've examined the images using exif, exiv2, etc. Any suggestions? Here is the code I'm using so far: result.itemProvider.loadDataRepresentation(forTypeIdentifier: UTType.image.identifier) { data, err in if let data = data { let src = CGImageSourceCreateWithData(data as CFData,nil)! let md = CGImageSourceCopyPropertiesAtIndex(src,0,nil) as! NSDictionary let md2 = CGImageSourceCopyMetadataAtIndex(src,0,nil) }
Replies
1
Boosts
0
Views
1.5k
Activity
Feb ’23
CGImageCreate() returns nil.
CGFloat width = any value;  CGFloat height = any value; CGDataProviderRef dataProviderRef = dataProviderRef = CGDataProviderCreateWithData(NULL, data, width * height * 2, nil); CGBitmapInfo bitmapInfo = kCGBitmapByteOrderMask | kCGImageAlphaNoneSkipLast; CGImageRef imageResult = CGImageCreate(width, height, 8, 16, width * 2, CGColorSpaceCreateDeviceGray(), bitmapInfo, dataProviderRef, NULL, 0, kCGRenderingIntentDefault); imageResult is nil. Please tell me an alternative method.
Replies
1
Boosts
0
Views
838
Activity
Feb ’23
The problem that different color tone of heif file on Ventura 13.2
Hi ! I'm testing my HEIF image files on Ventura 13.2 and I found something about different color-tone on Finder's Gallery. Shortly I explain it, Gallery in Finder app shows a HEIF image shows more brighter than Preview app. It did not happen on Ventura 13.1, just happen in 13.2. In order to explain more detail, I attached PPT file and image files. PPT: https://docs.google.com/presentation/d/1743G7KcSGChSFVvmCF0JR-EsBeXkJtLAGpmu6lkgMHU/edit?usp=share_link Image: https://drive.google.com/file/d/1ImfCEWuOhGOLpwsgc5KwRVFTCtVAiZtz/view?usp=share_link So, hopefully, I'm expecting you guys to check this problem and answer this post! Eventually, I hope you fix up this issue that I addressed in this post. Thanks. Seunghoon Baek.
Replies
1
Boosts
0
Views
690
Activity
Feb ’23