Xamarin mac 2.10 兼容的 exif 库
Xamarin mac 2.10 compatible exif library
我在更新前使用了 https://www.nuget.org/packages/ExifLib.PCL/ 库。
我现在无法使用这个库:
Could not install package 'ExifLib.PCL 1.0.1'. You are trying to
install this package into a project that targets
'Xamarin.Mac,Version=v2.0', but the package does not contain any
assembly references or content files that are compatible with that
framework. For more information, contact the package author.
还有其他选择吗?
我使用 Exif 库获取图像拍摄日期:
using (var stream = File.Open (filePath, FileMode.Open)) {
var ein=new CGImagePropertiesExif ();
var jpegInfo = ExifReader.ReadJpeg (stream);
if (jpegInfo.DateTimeOriginal != null) {
takenDate = DateTime.ParseExact (jpegInfo.DateTimeOriginal, "yyyy:MM:dd HH:mm:ss", null);
}
}
此代码终止应用程序,也看不到任何异常:(
如果我只是模拟 datetime ,像这样:
static DateTime GetMyImageTakenDate (NSUrl url)
{
DateTime takenDate = DateTime.Today;
using (var stream = File.Open (url.Path, FileMode.Open)) {
takenDate = DateTime.ParseExact (DateTime.Now.ToString ("yyyy:MM:dd HH:mm:ss"), "yyyy:MM:dd HH:mm:ss", null);
}
return takenDate;
}
应用程序工作正常:/
你的代码对我来说工作正常:
var filePath = "/Users/sushi/Desktop/img_1771.jpg";
using (var stream = File.Open(filePath, FileMode.Open))
{
var jpegInfo = ExifReader.ReadJpeg(stream);
if (jpegInfo.DateTimeOriginal != null)
{
var takenDate = DateTime.ParseExact(jpegInfo.DateTimeOriginal, "yyyy:MM:dd HH:mm:ss", null);
Console.WriteLine(takenDate);
}
}
输出:
12/14/2003 12:01:44 PM
使用:
Xamarin.Mac Version: 2.10.0.105
ExifLib.PCL Version: 1.0.2-pre01
我在更新前使用了 https://www.nuget.org/packages/ExifLib.PCL/ 库。
我现在无法使用这个库:
Could not install package 'ExifLib.PCL 1.0.1'. You are trying to install this package into a project that targets 'Xamarin.Mac,Version=v2.0', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.
还有其他选择吗?
我使用 Exif 库获取图像拍摄日期:
using (var stream = File.Open (filePath, FileMode.Open)) {
var ein=new CGImagePropertiesExif ();
var jpegInfo = ExifReader.ReadJpeg (stream);
if (jpegInfo.DateTimeOriginal != null) {
takenDate = DateTime.ParseExact (jpegInfo.DateTimeOriginal, "yyyy:MM:dd HH:mm:ss", null);
}
}
此代码终止应用程序,也看不到任何异常:(
如果我只是模拟 datetime ,像这样:
static DateTime GetMyImageTakenDate (NSUrl url)
{
DateTime takenDate = DateTime.Today;
using (var stream = File.Open (url.Path, FileMode.Open)) {
takenDate = DateTime.ParseExact (DateTime.Now.ToString ("yyyy:MM:dd HH:mm:ss"), "yyyy:MM:dd HH:mm:ss", null);
}
return takenDate;
}
应用程序工作正常:/
你的代码对我来说工作正常:
var filePath = "/Users/sushi/Desktop/img_1771.jpg";
using (var stream = File.Open(filePath, FileMode.Open))
{
var jpegInfo = ExifReader.ReadJpeg(stream);
if (jpegInfo.DateTimeOriginal != null)
{
var takenDate = DateTime.ParseExact(jpegInfo.DateTimeOriginal, "yyyy:MM:dd HH:mm:ss", null);
Console.WriteLine(takenDate);
}
}
输出:
12/14/2003 12:01:44 PM
使用:
Xamarin.Mac Version: 2.10.0.105
ExifLib.PCL Version: 1.0.2-pre01