How to pass imageView as source to QuickLook preview - ios

After picking an image from UIImagePickerController, I am trying to pass that imageView as a source to QuickLook preview which requires URL as a data source.
I am not interested to write the image into any document storage to create a URL, which will create a copy image again in the disk.
Note:
I am using a scanner SDK where it will return a UIImage as a result, so i need to use that UIImage for QuickLook preview.
Any suggestion to achieve this?

You might want to checkout this method (https://developer.apple.com/documentation/uikit/uiimagepickercontrollerdelegate/1619126-imagepickercontroller). One of the arguments to this method is an 'info' dictionary which can be used to get the image URL. Use the key 'imageURL'.

Related

Nativescript Mediafilepicker customizing DKImagePickerController UI

I'm currently using Nativescript-Mediafilepicker plugin to handle image selection and also capturing image from camera in iOS. In ns mediafilepicker docs , i can see that it is using DKImagePickerController native libraries to handle the image selection and In the DKImagePickerController docs, i can see there is an option to customize the UI (CustomUIDelegate).
Is there any possible way to do the same with Nativescript? I wish to customize the camera icon in the image picker gallery. In the DKImagePickerController CustomUIDelegate doc, i can see it is using DKAssetGroupDetailBaseCell to achieve the customization. How can i do this in Nativescript Angular?
Short answer: you cannot do it easily.
Long Answer
You need to override methods since the plugin you are referring to does not expose APIs to modify the icon.
I have tried modifying it myself and I found out modifying the original plugin source code. I can give you hints on what you would have to do based on the understanding I have put in during the last few hours.
Create your custom MediaPicker
class MyMediaPicker extends Mediafilepicker {
...
}
Extend and copy the original openImagePicker method.
As you can see in the original source code, you have access to the picker, but you need to create a custom iOS delegate that handles the task of getting the UIImage for the camera.... This last task is painful, since the DK plugin guy created a custom class to refer to the Camera Cell that you now have to modify as well.
Once you modify (1) the picker plugin method, (2) the internal DK picker delegate, and (3) created a custom CameraCell. You should be able to modify that camera icon.
Here are some useful links:
https://github.com/jibon57/nativescript-mediafilepicker
https://github.com/zhangao0086/DKImagePickerController/blob/e61f49bda664e41dafd3c06174ae0cd1eccda236/Sources/DKImagePickerController/DKImagePickerController.swift
https://github.com/zhangao0086/DKImagePickerController/blob/e61f49bda664e41dafd3c06174ae0cd1eccda236/Sources/DKImagePickerController/Resource/DKImagePickerControllerResource.swift

Image picker crash - iOS Swift

I have some code that will select an image from either the user's photo library or from their camera and display it in an image view. I'm accessing the photo URL from the following line of code:
let pickedPhotoURL: URL = (info["UIImagePickerControllerImageURL"] as? URL)!
This works perfectly when accessing a photo from the user's library. However, I'll always get a nil value at this line why trying to access the photo via the camera. Anyone have any ideas / suggestions?
It's because that value isn't set for a camera. Use UIImagePickerControllerOriginalImage (or edited image if you are using that).
That key gives you a UIImage -- if you need a URL, you need to save it somewhere.
Also, don't use strings, there are keys defined for you.

UIImage orientation issue in Share Extension

I am trying a Share Extension that iOS provides. Having trouble while getting UIImage from gallery host.
The image is is not in appropriate orientation. Any suggestion how can i get proper image from Photos as host to Share extension.
I am using loadItemForTypeIdentifier of NSItemProvider to get image object.
Kindly help, thanks in advance.

How to get the gif which copied from safari from UIPasteboard

I am trying to get the copied gif from UIPasteboard, but what's the pasteboard type going to be? The com.compuserve.gif or kUTTypeGIF. Should I use
- valueForPasteboardType: or just use image property to get the gif?
This works for me:
UIPasteboard.generalPasteboard().setData(myGifData as! NSData, forPasteboardType:"com.compuserve.gif")
I think one of the proper way to store images in pasteboard is as NSData.Then reconstruct UIImage from NSData.

Take photo and store in custom album in Xamarin.iOS

I want to take a photo and save them within a custom album on a iPad.
I tried a lot of things but ended always with wrong image orientation.
My current procedure is:
Take photo with Xamarin.Media and safe image somewhere in my app path
Create custom album if it's not existing
Load image from temporary path and save to the album
Add the image (asset) additionally to the custom album created in 2.
The workflow above is fully working except of saving the correct orientation. After loading an image with library.AssetForUrl() the containing orientation is every time up. Also after converting from asset -> CGImage -> UImage (uiImage.Orientation).
In step 3 I tried to set the orientation the the appropriate one with
var image = new UIImage(tempImage.CGImage, 1.0f, UIImageOrientation.MyOrientation)
and also with the save command
library.WriteImageToSavedPhotosAlbum(image.CGImage, myOrientation, SaveCompletionBlock)
But the orientation is still ignored. I checked this by opening the Album application as well as loading the file in my self written gallery app.
I want to avoid the use of the iOS picker to take photos. This will produce a mess of code!
Or is there any third party library which allows to take photos and store them in a custom album? Which takes care of all the metadata information? It doesn't matter if it's written in objective-c or c#. I will create bindings for it. But it's awful to work with the camera and albums in iOS.
There are tons of hand-made UIImagePickerController alternatives. Some of them:
https://github.com/w5mith/WSAssetPickerController
https://github.com/chute/photo-picker-plus-ios
https://github.com/B-Sides/ELCImagePickerController

Resources