Photos and Imaging

RSS for tag

Integrate still images and other forms of photography into your apps.

Posts under Photos and Imaging tag

84 Posts
Sort by:
Post not yet marked as solved
1 Replies
518 Views
I am using AVCapturePhoto to capture image. In didFinishProcessingPhoto i am getting image data using fileDataRepresentation. But when i convert this data to UIImage, it loses most of its metadata. I need to draw bezier path on UIImage and still maintain metadata. Is there any way to do this.
Posted
by
Post not yet marked as solved
0 Replies
278 Views
Hello our wonderful Apple community, I'm so glad to be able to get some assistent regarding my inquiry. I just wanted to say that, since the last few months, I’ve bean very tired, exhausted and wasting a lot of hours of my days searching and figure out where to find the right applicable images for building my iOS app. I’ve checked many varies websites that can enable you to download free/ paid images, but I’m having a very hard time to compare the images to my app idea: size, vertical form, the activity in the image. I do review all the apps that has the similar idea in the App Store and I always wonder, how the developers find and pick these images to create their apps! I wish to get your support relating to this topic and the rest is easy. Thank you guys Kindly,
Posted
by
Post not yet marked as solved
1 Replies
503 Views
Hello Everyone, We have a feature in our application wherein our user can upload a picture or a video for others to look into. We would like to add some compression logic to both the media types when uploaded so we can save the memory and our users can also upload the media quickly and don’t have to wait for a longer time. We have tried adding iOS native compression however that is degrading the quality of the photo or a video. Can you please help us with the best possible solution which we can integrate without losing the quality of the media? As an alternative for now, we are restricting the users to upload the video of max 30 seconds but if we are able to integrate the compression, we would like to allow them to upload a video of 3 mins. Please let us know if you need any additional information. Thank you.
Posted
by
Post not yet marked as solved
0 Replies
371 Views
I customize the captured portrait mode photo's depthData by using fileDataRepresentationWithCustomizer method, and replace the depth data with my edited version. - (nullable AVDepthData *)replacementDepthDataForPhoto:(AVCapturePhoto *)photo{ return myEditedDepthData; } The weird thing is that the returned NSData value of fileDataRepresentationWithCustomizer losts portraitMatte. CGImageSourceRef imageSource = CGImageSourceCreateWithData((CFDataRef)nsData, NULL); CFDictionaryRef dicRef = CGImageSourceCopyAuxiliaryDataInfoAtIndex(imageSource, 0, kCGImageAuxiliaryDataTypePortraitEffectsMatte); the dicRef always return 0x0 after I use fileDataRepresentationWithCustomizer instead of fileDataRepresentation Does anyone know what am I doing wrong?
Posted
by
Post not yet marked as solved
1 Replies
288 Views
Hi, I have a UIScrollView, that scrolls a number of images horizontally and inside a UIImageView added programmatically. Images are displayed in "scaleaspectfit" mode. Is there a way to avoid these images from moving freely inside the UIImageView? I have attached 3 screenshots showing the image move up or down just by dragging it. Thank you
Posted
by
Post not yet marked as solved
1 Replies
1k Views
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
Posted
by
Post not yet marked as solved
0 Replies
229 Views
I loathe updates as it seems to scupper functions more often than fix anything. STILL unable to post animated gifs (static) whereas if I reach for my trusty clunky old 5 series rather than relatively new ipad - it works just fine. Saying nothing bout 🍏’s & their questionable cores! 🤐
Posted
by
Post not yet marked as solved
1 Replies
503 Views
Hi everyone. When i update my iPhone Xs to ios 15 beta 6 live text stop working. Before this update it works excellent. After 7 and 8 beta it still doesn’t work. What should i do?
Posted
by
Post marked as Apple Recommended
744 Views
After a user complained that they could no longer load partially transparent PNG images in my photo compositing app, I eventually tracked this down to a bug in iOS 15.1 (tested on beta 2). When the user selects a PNG image in the PHPickerViewController, the returned NSItemProvider reports having a file for the "public.png" UTI (and only that one). However when requesting data for that UTI, the system actually returns JPEG image data instead. Just a heads up to other developers who might run into this. Hopefully it will get fixed before 15.1 ships. I reported it as FB9665280.
Posted
by
Post not yet marked as solved
2 Replies
510 Views
I need to add frames to auto-generated screenshots for multiple devices and multiple languages so that I can display these on my app's landing page. I guess it must be quite a standard task so my question is: Is there anything that can be reused to get this job done? All screenshot file names contain: language device name generation I would prefer not to have to manually add frames to 10 screenshots * number_of_devices * number_of_languages. Right now I actually only need iPhone Pro (not Max) and iPad Pro 12.9 (newest gen), but in the future I might need it for other devices too.
Posted
by
Post marked as solved
3 Replies
952 Views
Hi, I'm new to iOS mobile software dev (swift) and I'm trying to use the image literal function. I'm following a tutorial and the image literal function auto-populated on the tutorial but not on my x code. The tutorial is a few years old so maybe this function was removed since updates? When I type imageview.image = ImageLiteral the image literal function does not auto detect and I have nothing to select in order to grasp my photo from. Any help would be appreciated. Screen shot of what I am trying to convey is below.
Posted
by
Post not yet marked as solved
1 Replies
380 Views
The newish PHPicker is a great way to access the users’ photo library without requiring fill access permissions. However, this is currently no way for accessing the original or unadjusted version of an asset. The preferredAssetRepresentationMode of the PHPickerConfiguration only allows the options automatic, compatible, and current, where current still returns the asset with previous adjustments applied. The option only seems to impact potential asset transcoding. In contrast, when fetching PHAsset data, one can specify the PHImageRequestOptionsVersion unadjusted or original, which give access to the underlying untouched image. It would be great to have these options in the PHPicker interface as well. The alternative would be to load the image through PHAsset via the identifier returned by the picker, but that would require full library access, which I want to avoid. Or is there another way to access the original image without these permissions?
Posted
by
Post not yet marked as solved
0 Replies
250 Views
I am trying to set the description of an image. The metadata tag necessary to add the description is of type alternateText. I create the child tag with the new description value: let childTag = CGImageMetadataTagCreate(identifier.section.namespace, identifier.section.prefix, "[x-default]" as CFString, .string, value as CFTypeRef) I then set the description tag like this: let parentTag = CGImageMetadataTagCreate(identifier.section.namespace, identifier.section.prefix, identifier.tagKey, .alternateText, [childTag] as CFTypeRef) let result = CGImageMetadataSetTagWithPath(metadata, nil, identifier.tagKey, parentTag) However, when I write the image file, I get a runtime error message and the operation fails: XMP Error: AltText array items must have an xml:lang qualifier So, I create the qualifier tag like this: let qualifierTag = CGImageMetadataTagCreate("http://www.w3.org/XML/1998/namespace" as CFString, "xml" as CFString, "lang" as CFString, .string, "x-default" as CFTypeRef) But I have not found a way to associate this qualifier tag to the child tag with the description value. What is the way to do it?
Posted
by
Post not yet marked as solved
1 Replies
442 Views
Code from wwdc20-10652 is used. Open PHPickerViewController Choose 1 photo Do nothing and dismiss Leak is shown as below. @IBAction private func chooseImagePressed(_ sender: Any) {     if #available(iOS 14, *) {       var configuration = PHPickerConfiguration()       configuration.filter = .images       let picker = PHPickerViewController(configuration: configuration)       picker.delegate = self       present(picker, animated: true)     } else {       // Fallback on earlier versions     } } extension PhotosVC: PHPickerViewControllerDelegate {   @available(iOS 14, *)   func picker(_ picker: PHPickerViewController, didFinishPicking results: [PHPickerResult]) {     dismiss(animated: true)   } }
Posted
by
Post not yet marked as solved
0 Replies
370 Views
Hello, I am trying to create an animated sequence of HEIC images but I cannot save the frame property duration. It seems this is a well know bug: https://github.com/SDWebImage/SDWebImage/issues/3120 The kCGImagePropertyHEICSDictionary is never saved. Here's a sample project to reproduce the bug: ImageIOHEICSEncodeDecodeBug.zip Has anybody managed to save this information in a HEIC sequence? Thanks! Here's how I am writing an reading the image sequence - (void)testHEICSBug {     // First, load an animated image (GIF)     // And you can change the type into png, which is an animated PNG format. Same result     NSData *GIFData = [NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"image1" ofType:@"gif"]];     CGImageSourceRef source = CGImageSourceCreateWithData((__bridge CFDataRef)GIFData, nil);     NSUInteger frameCount = CGImageSourceGetCount(source);     NSAssert(frameCount > 1, @"GIF frame count > 1");          // Split into frames array, encode to HEICS     NSMutableData *heicsData = [NSMutableData data];     CGImageDestinationRef destination = CGImageDestinationCreateWithData((__bridge CFMutableDataRef)heicsData, (__bridge CFStringRef)AVFileTypeHEIC, frameCount, nil);               for (int i = 0; i < frameCount; i++) {         // First get the GIF input image and duration         CGImageRef cgImage = CGImageSourceCreateImageAtIndex(source, i, nil);         NSDictionary *inputProperties = (__bridge_transfer  NSDictionary *)CGImageSourceCopyPropertiesAtIndex(source, i, nil);         NSDictionary *inputDictionary = inputProperties[(__bridge NSString *)kCGImagePropertyGIFDictionary];         NSTimeInterval duration = [inputDictionary[(__bridge NSString *)kCGImagePropertyGIFUnclampedDelayTime] doubleValue];         NSAssert(cgImage, @"CGImage not nil");         NSAssert(duration > 0, @"Input duration > 0");                                    // Then, encode into HEICS animated image         NSMutableDictionary *outputDProperties = [NSMutableDictionary dictionary];         outputDProperties[(__bridge NSString *)kCGImagePropertyHEICSDictionary] = @{(__bridge NSString *)kCGImagePropertyHEICSUnclampedDelayTime : @(duration)};         CGImageDestinationAddImage(destination, cgImage, (__bridge_retained CFDictionaryRef)outputDProperties);     }          // Output HEICS image data     BOOL result = CGImageDestinationFinalize(destination);     NSAssert(result, @"Encode HEICS failed");               // Next, try to use ImageIO to decode HEICS and check duration          CGImageSourceRef newSource = CGImageSourceCreateWithData((__bridge CFDataRef)heicsData, nil);     frameCount = CGImageSourceGetCount(newSource);     NSAssert(frameCount > 1, @"New HEICS should be aniamted image");     NSUInteger frameIndex = 1; // I pick the 2nd frame, actually any frame contains this issue.     NSDictionary *newProperties = (__bridge_transfer NSDictionary *)CGImageSourceCopyPropertiesAtIndex(newSource, frameIndex, nil);     NSDictionary *newDictionary = newProperties[(__bridge NSString *)kCGImagePropertyHEICSDictionary];     NSTimeInterval newDuration = [newDictionary[(__bridge NSString *)kCGImagePropertyHEICSUnclampedDelayTime] doubleValue];     CGImageRef newImage = CGImageSourceCreateImageAtIndex(newSource, frameIndex, nil);          // Now, check the HEICS frame duration, however, it's nil :(     // Only image is kept.     NSAssert(newImage, @"frame image is not nil");     NSAssert(newDuration > 0, @"Decode the HEICS (which encoded from GIF) will loss the frame duration"); }
Posted
by
Post not yet marked as solved
0 Replies
292 Views
Question says it all. I want the transparent pixels to pass through the taps / clicks / gestures, while the opaque pixels catches them. Obviously be able to control the behaviour would be even better, so I could ignore slightly translucent pixels too. Pre-processing is not possible, user images, so it's not easy. So far, the best I thought was to get a global gesture recognizer, and try to figure out where in my complex hierarchy this tap falls, and see if the image is underneath. But that seems overly complicated for something so simple and basic, really.
Post not yet marked as solved
0 Replies
375 Views
I am trying to use the PHPickerViewController to select images from my photo gallery and seeing the following error. Could not create a bookmark: NSError: Cocoa 257 "The file couldn’t be opened because you don’t have permission to view it I am using Xcode 12.5 on Mac M1 (macOS 11.2.3) And connecting to an iPhone 12 (IOS 14.8). The code in question private func getPhoto(from itemProvider: NSItemProvider) {             print(itemProvider.registeredTypeIdentifiers)             itemProvider.loadFileRepresentation(forTypeIdentifier: UTType.image.identifier) { url, error  in                 if let error = error {                     print("Encountered Error in loadFileRepresentation \(error.localizedDescription)")                 }                 if url != nil {                     print("Obtained url: \(String(describing: url))")                 } else {                     print("Could not obtain url")                 }                 let imageData = try! Data(contentsOf: url!)                 DispatchQueue.main.async {                     self.parent.mediaItems.append(item: PhotoPickerItem(with: UIImage(data:imageData)!))                 }             }                      }     } I can see that the itemProvider has the following representations. ["public.heic", "public.jpeg"] and I have tried UTType.jpeg.identifier as well.
Posted
by