I am storing the image into camera roll
library.SavePictureToCameraRoll(DateTime.Now.ToString() + ".jpg", e.ImageStream);
my Problem is How can i get the path of this image after storing this image.
On WP8, SavePictureToCameraRoll returns a Picture object on which you can call the GetPath method (don't forget to add the using Microsoft.Xna.Framework.Media.PhoneExtensions;)
var picture = lib.SavePicture(string.Format("test.jpg"), ms);
var filePath = picture.GetPath();
Unfortunately, on WP7 there is no way to get the path, because SavePictureToCameraRoll doesn't return anything.
Related
My application is trying to insert images to google drive sheet using google app script.
It works fine...
but it hang up intermittently with the response error from google script:
Exception: Error retrieving image from URL or bad URL:
https://drive.google.com/uc?id=1uvjg9_ZZg2sI5RYbPMEn6xXJhhnwuFyq&export=download.
The code is :
var fpm_mon_image = file_from_folder(id_folder_images , image_AR ) ; // get "image_AR" from folder
var url_mon_image = fpm_mon_image.getDownloadUrl() ;
var image = SpreadsheetApp.newCellImage().setSourceUrl(url_mon_image).setAltTextTitle(titre).toBuilder().build() ;
Utilities.sleep(1000); // for testing ...
SpreadsheetApp.flush();
Utilities.sleep(1000);
var rangeIma= fpm_sp.getRange(scal_li_SP +1, 2) ;
rangeIma.setValue(image).setVerticalAlignment('bottom') ; // stop here with error above
It works fine 5, 10 times then it hang up 2, 3, 5 times and then works fine again.... (I start loosing my hairs ;-))
I tried :
var srcfile = DriveApp.getFileById(id_mon_image);
srcfile.setSharing(DriveApp.Access.ANYONE_WITH_LINK, DriveApp.Permission.VIEW);
var image = fpm_sp.insertImage(srcfile.getBlob(), my_col , my_row);
but the image in not inserted in a cell...
Could you help please ?
Many thanks.
Unfortunately, I cannot replicate your situation of Exception: Error retrieving image from URL or bad URL:. So, although I'm not sure about your actual situation, how about the following modification?
Modified script:
Before you use this script, please enable Drive API at Advanced Google services.
var fileId = "###"; // Please set the file ID of your image.
var url = Drive.Files.get(fileId).thumbnailLink.replace(/\=s.+/, "=s512");
var title = "sample title";
var image = SpreadsheetApp.newCellImage().setSourceUrl(url).setAltTextTitle(title).build();
var sheet = SpreadsheetApp.getActiveSheet();
sheet.getRange("A1").setValue(image);
When this script is run, a thumbnail link is retrieved from the image file using Drive API. And, the image size of the image is changed. And, the image is put to the cell "A1" of the active sheet.
In this case, if the issue of image size occurs, this issue can be removed. And, if the issue of sharing the file occurs, this issue can be also removed. By this, I thought that your issue might be able to be removed.
I have an image with longitude and latitude coordinates, can any one tell me how do i get it? I have tried
if (CrossMedia.Current.IsPickPhotoSupported)
{
MediaFile photoPicked = await CrossMedia.Current.PickPhotoAsync();
if (photoPicked != null)
{
//await DisplayAlert("Photo Location", photoPicked.Path, "OK");
//path = photoPicked.Path;
using (Stream streamPic = photoPicked.GetStream())
{
var picInfo = ExifReader.ReadJpeg(streamPic);
ExifOrientation orientation = picInfo.Orientation;
//MainImage123.Source = ImageSource.FromStream(() => photoPicked.GetStream());
latitude = picInfo.GpsLatitude;
longitude = picInfo.GpsLongitude;
var filepath = photoPicked.AlbumPath;
var filepath1 = photoPicked.Path;
}
}
}
It works when I picked photo and trying to get its coordinates, but I have to take multiple photos from image gallery and find its coordinates.
does any one know how to read image geo coordinates? please help me.
You can use the ExifLib.PCL Nuget Package to read an image metada, by viewing your "code sample", i think you are using the Plugin.Media to take images/get images from the galery, be sure to use SaveMetaData = true when taking an photo from your app.
Once you have set the SaveMetaData to true, use the ExifLib to obtain the MetaData like this:
MediaFile photo;
using (Stream streamPic = photo.GetStream())
{
var picInfo = ExifReader.ReadJpeg(streamPic);
double lat = picInfo.GpsLatitude;
double lon = picInfo.GpsLongitude;
}
Also, as a plus, you have even more info on the photo (date taken, author, size, etc.).
UPDATE:
After Reading it again, it seems that the problem is that you are not able to pick multiple images from the galery, and NOT being able to get the lat and lon from the photos. At the moment, Plugin.Media doesn't support multi-picking.
Your question was unclear however - I think you are trying to make it work with multiple images together. How you can be able to pick multiple images together?
The plugin "CrossMedia" doesn't support picking up multiple images.
Your solution requires a lot of work to be done to be able to Pickup multiple images at once. So Follow this nice step-by-step tutorial here:
https://xamgirl.com/select-multiple-images-from-gallery-in-xamarin-forms/
With above you will be able to get all the images you need at once.
After you get List, all you have to do is to loop through those images and call your existing code.
I have a folder with images: IMG1.jpg, IMG2.jpg, IMG3.jpg, IMG4.jpg.
I do:
BufferedImage _img = null;
_img = ImageIO.read(new File(PATH_TO_IMAGE + "\\IMG"+Id+".jpg")); //where id is the number.
Then the rest...
BufferedDynamicImageResource bufferedDynamicImage = new BufferedDynamicImageResource();
bufferedDynamicImage.setImage(_img);
Image ci = new Image("myImg", bufferedDynamicImage);
add(ci);
And what I get in the end is that although Wicket knows the exact path to some image (which is shown in Log.file) most time it gets random image from my folder. What could be the reason for this?
Following my comment, what about
Image ci = new Image("myImg");
ci.add(AttributeModifier.replace("src", Model.of(PATH_TO_IMAGE + "\\IMG" + Id + ".jpg")));
add(ci);
This changes the src-attribute of your img-tag according to your desired logic, prevents browser-caching where undesired but enables caching where possible.
In my javascript, in Windows 7, Photoshop CS2 & Photoshop CS5, it throws an error:
Error 8800: General Photoshop error occurred. This functionality may not be available in this version of Photoshop.
- Could not save a copy as "C:...\wcb-010B-11Y.jpg" because the file could not be found.
Line: 458
-> docRef.saveAs( saveFile, jpgSaveOptions, true, Extension.LOWERCASE );
here is a summary of the code to save the image:
var selectedSaveDir = "~/Desktop/";
var sFileNamePreFix = "wcb-";
var docRef = app.activeDocument;
var docName = app.activeDocument.name;
var docNewName = docName.substr( 0, docName.length - 4 ); // strip file extension
var sNewDocName = sFileNamePreFix + docNewName + ".jpg"
var sNewFileName = selectedSaveDir + sNewDocName;
//alert( "sNewFileName = " + sNewFileName ); // test to verify correct location
var saveFile = new File(sNewFileName);
jpgSaveOptions = new JPEGSaveOptions();
jpgSaveOptions.quality = 12;
docRef.saveAs(saveFile, jpgSaveOptions, true, Extension.LOWERCASE);
In Windows XP, this script works very well in CS2 with no problems.... just in Windows 7 is where this issue occurs using CS2 or CS5.
The problem seems to be similar to : Photoshop Javascript scripting saving and closing document
But I don't know his OS.
I've added the "alert(" and confirmed the save folder & name is correct and can be saved to, but same issue.
Could it be a UAC issue in Windows 7 ? and how do you Fix it ? I've turned off all UAC settings (I think I did it correctly), but it still occurs.
Any Help ?
You missed out " var docRef = app.activeDocument;" (which i've added); but apart from that, in CS2 the script saves out a jpeg to the desktop (wcb-text test.jpg). It's obvious, but have you made sure the image is flattened or doesn't contain any information that cannot be stored in a jpeg - like paths for example.
Try forcing a flatten before saving
//flatten the image
docRef.flatten();
Another thing to try is to save out the file to another directory. I know that long file names (especially with spaces in) can cause problems - I think there's a limit to 300 characters in the file path.
I just found that, in new versions of PS this particular path variable gives the error 8800:
var selectedSaveDir = "~/Desktop/";
Use full path instead and use apostrophes instead of quotes:
var selectedSaveDir = 'C:/Users/yourname/Desktop/';
When I use:
loader = new MovieClipLoader();
_root.createEmptyMovieClip("level1",getNextHighestDepth());
_root.level1.createEmptyMovieClip("image",getNextHighestDepth());
loader.loadClip("http://someimage.jpg",_root.level1.image);
...it works and the image shows up.
But when I use:
loader = new MovieClipLoader();
_root.createEmptyMovieClip("level1",getNextHighestDepth());
_root.level1.createEmptyMovieClip("level2",getNextHighestDepth());
_root.level1.level2.createEmptyMovieClip("image",getNextHighestDepth());
loader.loadClip("http://someimage.jpg",_root.level1.level2.image);
...the image doesn't show up. Can anyone tell me why? How can I make this work?
the depth you are supplying is going to be '1'. is that what you are expecting?
each movie clip has it's own set of depths, so the nextHighestDepth() of the newly create 'image' mc, will be 1. it should not prevent loading the image though.
As gthmb says, you should call getNextHighestDepth() on the same MovieClip as you do the createEmptyMovieClip() on. So your code example should be more like:
loader = new MovieClipLoader();
_root.createEmptyMovieClip("level1",_root.getNextHighestDepth());
_root.level1.createEmptyMovieClip("level2",_root.level1.getNextHighestDepth());
_root.level1.level2.createEmptyMovieClip("image",_root.level1.level2.getNextHighestDepth());
loader.loadClip("http://someimage.jpg",_root.level1.level2.image);
Also, I would recommend storing references to the created MovieClips, so you won't have to use the full path in each occurrence in the code, something in the lines of this:
loader = new MovieClipLoader();
var level1:MovieClip = _root.createEmptyMovieClip("level1",_root.getNextHighestDepth());
var level2:MovieClip = level1.createEmptyMovieClip("level2",level1.getNextHighestDepth());
var image:MovieClip = level2.createEmptyMovieClip("image",level2.getNextHighestDepth());
loader.loadClip("http://someimage.jpg",image);