Persistence of Image name using IOS8 Photos and iCloud Photo Sharing - ios8

I am working on an app using Core Data which includes a Product file containing item description and image filename. In a previous version on a different platform this filename would contain something like “elephant.jpg” and its associated image would also be called “elephant.jpg”. In this way the data could be entered and validated off-line and then imported into the app.
Using IOS8 and the Photos framework I cannot do this as there appears to be no way of persistently attaching a name to a photo image. I have tried looking at the image metadata using :
PHImageManager.defaultManager().requestImageDataForAsset(asset, options: nil) {
imageData,dataUTI,orientation,info in
println("Info %#", info) }
However this returns info such as
/private/var/mobile/Media/PhotoData/PhotoCloudSharingData/8083971319/2cc2fcd0-d19b-4803-b34f-35a285bc1fab/100CLOUD/**IMG_0008.JPG**
where IMG_0008.JPG is not related to the original image.
I am currently getting partially around this by ensuring each image has a unique dateTime for its creationDate, storing this in the Product.fileName and using this to retrieve my image with
var fetchOptions = PHFetchOptions()
fetchOptions.predicate = NSPredicate(format: "creationDate == %#", imageCreationDate) // use CreationDate in predicate
var assets = PHAsset.fetchAssetsInAssetCollection(rec, options: fetchOptions)
However this is difficult to manage, and not easy to create datafiles which can be exported as the image has to be matched to the file after it has been imported to the iPad.
My problem would be solved if I could only attach a name to the image on iPhoto on my Mac which persisted after I shared the images with iCloud Photo Sharing.
I will be very grateful for any suggestions !

Related

Storing FileURLs

I have an application that allows the user to load and display images. In the QML front end I am using a fileDialog to get the file URLs which are then loaded using an image loader in C++.
The issue I have at the moment is that if you want to load multiple images you have to load them all at once because once the fileURLs changes, the old URLs are lost.
What is the best way to go about storing the URLs so that I can keep the images displayed?
solution 1:
C++ side, Use a QStringList or a QVector to store paths and load Images from it. Qml side, each time you get new URL push it back to your QStringList.
solution 2:
Declare a qml array (property var array:[]) and store in it the new urls, load images from this list.

What are Default Picture Names from the Hardware Camera

I noticed that depending on how an image was taken or saved to the Windows Phone device, a different naming scheme may be used. For instance, a picture taken from the default camera application and saved to the Camera Roll will be WP_20131108_001.jpg, and a picture from screenshots would be wp_ss_20131108_0001.jpg, while the Saved Pictures album naming convention seems to be random based on where the picture came from. Is there a systematic naming scheme for pictures in different albums?
I need the ability to know when a picture was taken with my application or not in case it is used later (and it may be chosen from the PhotoChooserTask). I was thinking if there is no standard way to tell where a picture came from, then when saving an picture from my app I could put in a certain text value in the name and then check to see if a picture's name contains that text when being used in my app, and in that way flag to know whether a picture originally came from my application or not. Any suggestions?
You can use Album.Name functionality of Picture class to get the album name/source folder where the picture came from.And while saving in cameraroll or saved pictures you can provide a custom name for your picture.
fileName = "Camera_" + DateTime.Now;
MediaLibrary library = new MediaLibrary();
library.SavePictureToCameraRoll(fileName, stream);

Images save to saved pics and retrieving back and displaying in my app in windows phone

Hello Friends I am New to WP7
i am working on small app now..
In that App i take one Pic from my camera and trying to save that in saved pictures with some name and i like to retrieve that Images and display again in my App Gallery screen
I am Using Pivot control for this app
in my first PivotItem Name is Gallery and second PivotItem name is Camera
Now i am working with camera fine
After taking my picture from camera i like to add some Note for that and save to my saved images and retrieving same image back and display in Gallery with Note wt i save
can any one say
how can i complete this App in good way
Code for save Images im using
mainpage.xaml.cs
private void saveimg_Tap(object sender, System.Windows.Input.GestureEventArgs e)
{
string fileName = myValue.ToShortDateString() + ".jpg";
var library = new MediaLibrary();
//library.SavePictureToCameraRoll(fileName, e.ChosenPhoto);
library.SavePicture(fileName, imageBits);
MessageBox.Show("Photo Saved to Picture Hub");
}
I need to Retrieve that that saved Image and display in my App when it loaded
If you need to access your image once it has been saved in the Media Library, you should also save it to the Isolated Storage.
Here is a tutorial that shows how to do that:
http://www.windowsphonegeek.com/tips/All-about-WP7-Isolated-Storage---Read-and-Save-Images
Save the image to Isolated Storage and Pictures Gallery. When wanting to see the image through the app, use image from Isolated Storage.
No need to use SQLite, use index numbers to save your image in Isolated storage, and also store comments with index numbers, that might ease you.

Titanium mobile Get saved image path

i have been using this code to store an image from imageviewer to device memory.
blobObj = imageView.toImage();
var f = Titanium.Filesystem.getFile(Titanium.Filesystem.resourcesDirectory,'img.png');
f.write(blobObj);
Titanium.Media.saveToPhotoGallery(f,{
success: function(e) {
Titanium.UI.createAlertDialog({
title:'Photo Gallery',
message:'Check your photo gallery for image '
}).show();
},
error: function(e) {
Titanium.UI.createAlertDialog({
title:'Error saving',
message:e.error
}).show();
}
});
What i want is to get the native path of currently saved image from memory
Thankyou
Dear Please see the below example to get native path where the image is stored in titanium
file system
// Native path
var filename = "image.png";
// Create the file in the application directory
bgImage = Titanium.Filesystem.getFile(Titanium.Filesystem.applicationDataDirectory, filename);
// Write the image to the new file (image created from camera)
bgImage.write(image);
// bgImage.nativePath, it is alos native path, but you can get through below code.
nativePath = Titanium.Filesystem.applicationDataDirectory + Ti.Filesystem.separator + filename;
alert(nativePath);
Hopefully, it will for you. It is working on my side.
As this only works on iOS (see docs) i guess you are on iOS Platform.
If you create an image via blobObj = imageView.toImage(); you will receive a Titanium.Blob object. This object can be persisted somewhere in your app, it can also be temporarily available in memory.
If you store this image to the media gallery you won't get a file path to this image as this is not allowed by the iOS platform. So finally: What you want to do is not possible.
But: You can store the image yourself persistently within your app's data storage (using Ti.Filesystem).
To retrieve a file path for the temp object use f.nativePath or f.resolve().
Don't forget: You'll never get a path to the media gallery's photos. Even if you load an image from there you'll get a temporary path.

The proper way to insert an image in memory into Webview in Cocoa?

I have an image of a graph generated using the Core-Plot framework. I'd like to be able to insert the image into a custom report which is held in a Webview.
Is there an advised or best practise way of doing this. i.e. if the image needs to be saved to disk as a temporay file, where should the image be placed? When should the image be deleted etc.?
Assuming you control all the html that's to be rendered in the webview, I'd suggest saving a sort of local web archive, with the html, image and any other resources all in the same place, making your custom report's rendering much less prone to breaking. (You could even make it a supported bundle document type, if you get that far along.)
If you just need to have the file available for a one-time rendering of a modified html document, I suggest using the NSTemporaryDirectory() path:
NSData *imageData = ...;
NSString *temporaryImagePath = NSTemporaryDirectory();
NSError *error = nil;
temporaryImagePath = [ temporaryImagePath stringByAppendingPathComponent: #"img.jpg" ];
[ imageData writeToFile: temporaryImagePath options: NSDataWritingAtomic error: &error ];

Resources